JQuery formvalidator Form Validation plugin common issues

Source: Internet
Author: User

JQuery formvalidator Form Validation Plugin FAQ

  

  1. How do you implement a control that implements different controls depending on the situation?
  2. I have a few tab pages on a page, how do I implement a separate check for controls on each tab page?
  3. I adopt the way the text problem on the page, when the point of submission, there is no pass verification, in addition to the text hint, you can also pop-up window prompt?
  4. After all the checks have passed, do I have to make another judgment? Does my own judgment not pass can I interrupt the submission?
  5. I have a set of checkboxes (RadioButton) How to set the checksum?
  6. I have 2 form elements, any one element input things even if the validation passed, how to write code? For example, the need to enter Chinese name and English name any one of the check pass.
  7. A FORM element check passed, but I would like to make additional checks, error to customize the error, how to write code?
  8. How do I let the default validation pass for a form element that has an initial value assigned to it ?
  9. Ajaxvalidator check, leave the focus, immediately click the Submit button, this time the server has not returned to do?
  10. I think when the form does not pass the check, pop the first error message that does not validate through the element, how to implement?
  11. When I first opened the page I didn't want to show the status of OnShow, how to do this function
  12. Under a condition, a control is not tested, under the condition of B, the control is tested, how to implement?
  13. Inputvalidator Check mode, I would like to make more precise hints, how to write? That is, smaller than the minimum value, larger than the maximum, separate hints.
  14. How do I implement the autoenrollment Pageisvalid function? It's too much trouble to write on your own every time.
  15. When using Ajaxvalidator, the server can not get the value of the control, each time is empty, what is it?
  16. Automatically build the prompt layer when the function is turned on, found that the positioning is not accurate?
  17. Why does the report $.formvalidator invalid script error.
  18. Inputvalidator Besides judging the length, can you judge the left space and the right space again?
  19. Inputvalidator when verifying the length, can I verify the full-width character as a length?
  20. User input correct to leave the focus, how to set?
  21. How do I set the debug mode? After validation succeeds, no data is submitted.

  1. How to implement a control, depending on the situation, to achieve different control? [Top]

You just need to reset your in the different situations you have . For example:

if (condition)
$ ("#id"). Formvalidator ({Configuration 1}). Inputvalidator ({with 1});
Else
$ ("#id"). Formvalidator ({Configuration 2}). Inputvalidator ({with 2});

  2. On one page I have several tab pages, how do I implement a separate check for controls on each tab page? [Top]

On each tab page you need to verify the control, and when you write, explicitly declare the group number .
$.formvalidator.initconfig ({validatorgroup: "1"});
$.formvalidator.initconfig ({validatorgroup: "2"});
Then explicitly declare the group number Validatorgroup in Formvalidator, for example:
$ ("#id"). Formvalidator ({validatorgroup: "2" ...}). Inputvalidator ({...});

  3. I use the text problem on the page, when the point of submission, there is no pass verification, in addition to the text hint, you can also pop-up window prompt? [Top]

The problem is simple, you just set the global configuration of the reorganization,
JQuery.formValidator.initConfig ({onerror:function () {alert ("Partial check not passed, see page specific hint");}) .

  4. After all the checks have passed, do I have to make another judgment? Does my own judgment not pass can I interrupt the submission? [Top]

Also very simple, you only need to set the global configuration of the group,
JQuery.formValidator.initConfig ({onsuccess:function ()
{
if (your extra judgment fails)
return false;
Else
return true;
}})

  5. I have a set of checkbox (RadioButton) How to set the checksum? [Top]

You only need to set the verification information on the first checkbox of the group, please refer to the example in Demo1
1. If you have the ID of the first control of the group, you can write:
$ ("Sex_1"). Inputvalidator ({...})
2. If you only know the name of the group, you can write:
$ ("input:check[@name = ' sex ']"). Inputvalidator ({...})

  6. I have 2 form elements, any one element input things even if the validation passed, how to write code? For example, the need to enter Chinese name and English name any one of the check pass. [Top]

$ ("#name_cn, #name_en"). Formvalidator ({tipid: "Imtip", OnShow: "Please fill in any name)", onfocus: "Please fill in any name." ", Oncorrect:" Enter correctly! }). functionvalidator ({fun:allempty});

function Allempty (Val,elem)
{
Return ($ ("#name_cn"). val () = = "" && $ ("#name_cn"). val () = = "") ' if you want to chat with customers online, please fill in at least one IM software account! ': true;
}

  7. One verification group check passed, but I would like to make additional checks, error to customize the error, how to write code? [Top]

$ ("#ewjy"). Formvalidator ({
OnShow: "No matter what you enter, you will be prompted for additional check error, error message customization",
onfocus: "Enter at least one character",
Oncorrect: "How could you possibly enter the correct, is it a bug",
). Inputvalidator ({min:1,onerror: "At least one character here, please confirm"}). Functionvalidator ({
If (additional check failed)
Return "error message for additional checksum failure";
Else
return true;
});

  8. How do I make the default validation pass for a form element that has an initial value assigned to it ? [Top]

$ ("#xueli"). Formvalidator ({onshow: "Please select your qualifications", onfocus: "Education must be selected", Oncorrect: "Thank you for your cooperation", DefaultValue: "B"}). Inputvalidator ({onerror: "Did you forget to choose a degree!"}). defaultpassed ();

9.Ajaxvalidator Check, leave the focus immediately click the Submit button, this time if the server has not returned data what to do? [Top]

The new version of Ajaxvalidator provides a configuration parameter buttons (the button (group) jquery object you click Submit), and if you trigger an AJAX check, the corresponding button in buttons will be grayed out, waiting for the server to return the data. For example:
$ ("#test1"). Formvalidator ({...}). Inputvalidator ({...}). Ajaxvalidator ({
URL: "Default.aspx",
DataType: "JSON",
Success:function (data) {...},
Buttons: $ ("#button_id"),
Error:function () {alert ("The server is not returning data, the server may be busy, please retry");},
OnError: "The user name is not available, please replace the user name again",
Onwait: "The user name is being validated for legality, please wait ..."
});

  10. I think when the form does not pass the check, pop the first error message that does not validate through the element, how to implement? [Top]

OnError has 2 parameters: the first "error message with no validation through element"; the second "first no validation through element object"; The code is set as follows:
JQuery.formValidator.initConfig ({onerror:function (msg) {alert (msg);}}) .

  11. I do not want to show the status of OnShow when I open the page, how do I implement this function? [Top]

If the content of Onshow,onfocus,oncorrect,onerror is empty, the prompt content will not be displayed .

   under a condition, a control is not tested, under B conditions, the control is tested, how to implement ? [Top]

if (a condition)
{
$ ("#sfzh"). attr ("Disabled", true). Unformvalidator (True); De-Verify
}
Else
{
$ ("#sfzh"). attr ("disabled", false). Unformvalidator (false);//Recovery check
}

   inputvalidator Calibration mode, I would like to make more precise hints, how to write? [Top]

The Inputvalidator Check mode provides 2 properties, Onerrormin and Onerrormax, respectively.
Onerrormin: Error when the user enters a value that is smaller than the min attribute
Onerrormax: Error when the user enters a value that is larger than the Max property
Original OnError Property: Use this property to prompt for an error when onerrormin or Onerrormax does not exist

   How do I implement the auto-registration Pageisvalid function? Is it too much trouble to write yourself every time? [Top]

Automatically registers the $.formvalidator.pageisvalid () function, adding a Formid property to Initconfig, which represents the form ID number.
If the formid is empty, it must be judged by the old method.
Applicable environment: If you have only one validation group and you submit it using the form's submit, you can configure this formid parameter.
For example: $.formvalidator.initconfig ({formid: "Form1", Onerror:function (msg) {alert (msg)});

   When using Ajaxvalidator, the server can not get the value of the control, each time is empty, what is the matter? [Top]

See Update history
2008/1/22 23:58:57 jQuery formvalidator 1.1.2 ver
1. Add a Addidvalue property for Ajaxvalidator (whether to add ID and value automatically after the URL parameter)
In order to repair the Ajaxvalidator when the configuration information, not to get the runtime value of the bug
The plugin will automatically be added after the URL, in the form of "Id=value" page parameters
On the server side, you can take the value by request.querystring["id")
For specific demos, see username input and default.aspx in Demo1.

2008/3/14 12:16:00 jQuery formvalidator 2.2 ver
2, Ajaxvalidator check mode, will automatically add another parameter to the requested address "clientid= trigger check the form ID."
If you are a jquery collection for validation, if you use the Ajaxvalidator check method, on the server side, you cannot know which form element is triggering the checksum, so append the "clientid= trigger check" form ID after the requested address.

The question you say is "When you configure the information, you can not get the runtime value of the bug", you may refer to the DEMO1 user name of the wording

   When the auto-build cue layer function is turned on, you find that the positioning is not accurate? [Top]

Add an attribute to the Formvalidator function: Tipcss, which is used to position the automatic cue layer. This property is a standard CSS property declaration.
For example: tipcss:{"Top": "1px", "left": "20px"}. Note that attribute names and values must be quoted

When the auto-build cue layer is turned on, the original Tipid property represents the ID number of the target control that is relatively positioned
When you turn off the auto-build cue layer, the meaning of the original Tipid property is constant, indicating the ID number of the cue layer

   Why does the report $.formvalidator invalid script error? [Top]

    1. Please check that the plugin's script is referenced correctly first.
    2. Plug-in scripts are UTF-8 encoded, if your page is encoded in other ways, you should explicitly indicate how the script is encoded when you reference the script
      <script src= "Formvalidator.js" type= "Text/javascript" charset= "UTF-8" $amp;>amp; $lt;/script>

   Inputvalidator Besides judging the length, can you judge the left space and the right space? [Top]

    1. In the new version 3.1, the empty property is set for Inputvalidator, which sets whether the text value of the control allows both sides to be empty
    2. See the password control in Demo1.

      $ ("#password1"). Formvalidator ({onshow: "Please enter password", onfocus: "Password cannot be empty", Oncorrect: "Password is valid"}). Inputvalidator ({min:1,empty: {leftempty:false,rightempty:false,emptyerror: "Cannot have empty symbol on both sides of password"},onerror: "Password cannot be empty, please confirm"});

   Inputvalidator When verifying the length, can the full-width character be verified as a length? [Top]

Initconfig has a property: Wideword, which indicates whether full-width characters are treated as 2 lengths, and the default is true.

   user input correct to leave the focus, how to set? [Top]

Increase the Forcevalid property for Initconfig, Formvalidator increase the Forcevalid property to indicate whether to leave the focus until it has been entered correctly. The Initconfig Forcevalid has the highest priority, that is, the global configuration, while the Forcevalid in Formvalidator is the local setting.
See validation of the Demo1 mailbox field.

   How do I set the debug mode? After validation succeeds, no data is submitted. [Top]

Initconfig has a property called Debug, Default false. If you want to debug the code, you can set debug to True, the checksum is successful, and the form is not submitted.

JQuery formvalidator Form Validation plugin common issues

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.