Wednesday, 15 January 2014

validation - how to can I use element name including dot for jQuery form valiator plugin -


I am using the jQuery and Form Verifier plugin and it works well except for one page shown below.

  HTML: & lt; Form method = "POST" enctype = "multipart / form-data" id = "frmReg" class = "form-horizontal" novalidate = "novalidate" & gt; & Lt; Input type = "hidden" name = "mode" id = "mode" value = "insert" & gt; & Lt; Input type = "hidden" name = "filename" id = "fileName" & gt; & Lt; Div class = "control-group" & gt; & Lt; Label id = "fileLabel" class = "control-label" & gt; * File name & lt; / Label & gt; & Lt; Div class = "control" & gt; & Lt; Input type = "file" name = "file" id = "file" placeholder = "select file" required = "required" square = "valid" & gt; & Lt; / Div & gt; & Lt; / Div & gt; & Lt; Div class = "control-group" & gt; & Lt; Label class = "control-label" & gt; * Package name & lt; / Label & gt; & Lt; Div class = "control" & gt; & Lt; Input type = "text" name = "id.appId" id = "appId" placeholder = "type group id" tabindex = "0" class = "valid" & gt; & Lt; / Div & gt; & Lt; / Div & gt; & Lt; Div class = "control-group" & gt; & Lt; Label class = "control-label" & gt; * Application title & lt; / Label & gt; & Lt; Div class = "control" & gt; & Lt; Input type = "text" name = "appName" id = "appName" placeholder = "type the name of the application" class = "valid" & gt; & Lt; / Div & gt; & Lt; / Div & gt; & Lt; Div class = "control-group" & gt; & Lt; Label class = "control-label" & gt; * Version & lt; / Label & gt; & Lt; Div class = "control" & gt; ** & lt; Input type = "text" name = "id.version" id = "version" placeholder = "type version" tabindex = "0" class = "valid" & gt; ** & lt; / Div & gt; & Lt; / Div & gt; & Lt; Div class = "control-group" & gt; & Lt; Label class = "control-label" & gt; Details & lt; / Label & gt; & Lt; Div class = "control" & gt; & Lt; Textarea name = "description" id = "description" placeholder = "type description" class = "valid" & gt; & Lt; / Textarea & gt; & Lt; / Div & gt; & Lt; / Div & gt; & Lt; Div class = "modal-footer" & gt; & Lt; Button aria-hidden = "true" data-rejected = "modal" class = "btn" & gt; Close & lt; / Button & gt; & Lt; Button class = "btn btn-primary" type = "submit" & gt; Submit & lt; / Button & gt; & Lt; / Div & gt; & Lt; / Form & gt; Valid JS: $ ("#framereg") (For hidden field rules {{ignore: "",}}: {version: {expected: true, number: true}}, message: {version: {required : "Enter version number", number: "decimal number is allowed only."}}}}; ** $ ("# frmReg") Valid (). Element ("# version"); **   

This works when I use the 'version' as the input name but I have the input name instead of the 'version' due to the server-side framework To use 'id.version' as the name but when I use the name, the verification code is always correct, even when I type a special character and character I am the id.version for the element How can i use Your reply will be appreciated.

...

field with complex name ( Brackets, dots)

If your form contains fields containing names that are not legal JavaScript identifiers, you must quote those names when using the rules

Simply put quotation marks around points with name

 Validate $ ("# frmReg") ({ignore: For hidden field rules: {'id.version': {Required: true, number: true}}, Message: {'id.version': {Required: "Enter version number", number: "decimal number allowed only."}}}};   

Working demo:

No comments:

Post a Comment