jquery validation only digits
to check it add $(“#myform”).validate({ rules: { amount: { required: true, digits: true } } }); http://docs.jquery.com/Plugins/Validation/Methods/digits
to check it add $(“#myform”).validate({ rules: { amount: { required: true, digits: true } } }); http://docs.jquery.com/Plugins/Validation/Methods/digits
In case someone else comes across this, the jQuery-UI dialog does not append to the form, it appends just before </body>, so the elements to validate are outside the <form></form> section: To resolve this, just direct the dialog to move itself inside the form when you create it, like this: $(“#mydiv”).dialog(“open”).parent().appendTo(jQuery(“form:first”));
Take a look at this: http://thewayofcode.wordpress.com/tag/custom-unobtrusive-validation/ Using this tutorial I got my custom validation code running with no problem. The only difference I can spot in your code is the way you created the $.validator.unobtrusive.adapters.add function. The parameters are a little bit different but, maybe, the problem is just that you have not defined the … Read more
Javascript arrays: [value1,value2,value3] SO your code might be: inputEl: { required: true, math: [2, 3 ,4 , 5] }
I have found the problem. The problem was that the HTML I was trying to validate was not contained within a <form>…</form> tag. As soon as I did that, I had a context that was not null.
This isn’t the answer you want to hear, but the other answer is incorrect (it may have been right when it was posted, but there have been several major jQuery validation plugin changes since then). The validation plugin is (currently) designed to work on a <form>, and only on a <form>. You can also note … Read more
$(“#signupform”) .validate({ rules: { password: “required”, postcode: { required: true, minlength: 3 } }, messages: { password: “Field Password is required”, postcode: { required: “Field PostCode is required”, minlength: “Field PostCode must contain at least 3 characters” } });
You can use the :not() selector: ignore: “:hidden:not(.my_item)”
I ran into this same problem. A hidden field on a page was storing a user ID, which was selected from an autocomplete text box. This ID had validation to ensure that a non-zero id was posted back. We wanted to include this validation in the client side. By default jQuery validate ignores hidden fields, … Read more
In my code instead of using $.validator.setDefaults I access the form validator using $(“#form_selector”).data(‘validator’) and then change the settings. $(function () { var validator = $(“#form_selector”).data(‘validator’); validator.settings.errorPlacement = function(error,element) { alert(‘errorPlacement’); }; }); See if it works for you.