jQuery Validation Plugin - Submit only after checking a variable -
i have done small validation myself , end either - myvalid = true or mayvalid = false. how can add check validation doing on form using validation plugin?
you can use .addmethod()
add custom validation methods validation plugin.
http://docs.jquery.com/plugins/validation/validator/addmethod#namemethodmessage
update:
here's example can test: http://jsfiddle.net/w8esu/
html
<form id='theform'> <input id='test_field' name='test_field' value='jquery' /> <br> <input id='test_field2' name='test_field2' value='prototypejs' /> </form>
jquery
// add validation method validator plugin // can applied rule whatever fields // want. way custom validation // integrated functionality of plugin $.validator.addmethod( "mustincludejquery", function(value, element) { return value.tolowercase().indexof('jquery') > -1; }, "you must type jquery valid." ); // apply custom validation fields $('#theform').validate({ rules: { test_field:'mustincludejquery', test_field2:'mustincludejquery' } }); // demonstrates executed // other validation rule. $('#theform').valid();
Comments
Post a Comment