开发者

jQuery plugin: Validation can't be customized without setting all fields to 'required'?

I've spent the day looking at jQuery plugin: Validation by Jörn Zaefferer. I notice that it works fine as long as you call the validate() method without options. In my little squalid world, as soon as I add options, like errorPlacement, I notice that validation ignores form fields that are not marked required. I also notice that many, many demos mark开发者_如何转开发 all fields required---or do not pass options. Am I writing about anything familiar here? Or should I astral project to a parallel universe?


Note: This is to close the question out and provide info to resolve this to the next person finding the question since the OP has resolve the issue.

If there are any errors in the options, it will act the same as ignoring the fields, this isn't the validation plugin behavior per se, but rather how javascript works overall...any errors and it blows up (in mosts cases).

Double check all your options and use either Chrome's tools or FireBug to see if there are any script errors at all. Judging from your question, this seems the most likely culprit, fixing any errors in your options/errorPlacement will eliminate the onstacle in making the validation plugin work.

Also for testing, it's very helpful to use the debug option on the validation plugin, like this:

$("form").validate({
  //other options
  debug: true
});

This prevents the form from actually submitting, allowing you to tweak the validation much faster.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜