I had a small problem when using the jQuery validation plugin in my .net / MVC projects: Validation usually works fine, the problem occurs during submission: I want the form not to be submitted if it has any validation errors , and for this I installed debug: true;
But after setting it to true, when the submit button stops responding, even if everything is in order, that is, no verification errors, nothing happens, just by pressing the submit button. And if you remove debug: true, it will submit the form, even if it has validation errors. I want to solve this problem, the middle way, that is: When you click the "Submit" button, if there are errors, it does not send the form and shows errors And if there are no errors, then simply sends them.
Help plz .. Thanks!
<script type="text/javascript"> $(document).ready(function() { $("#productSubmit").validate( { debug : true, rules : { prdctttle : { maxlength : 50, required : true, onlyChars : true } , prdctdscrptn : { maxlength : 250, required : true, onlyChars : true } } , messages : { } } ); } ); $.validator.addMethod('onlyChars', function (value) { return /^[a-zA-Z ,-!]+$/.test(value); }, 'Please enter a valid name with only alphabets'); $("#productSubmit").validate( { submitHandler : function(form) { if ($(form).valid()) form.submit(); return false; </script>
javascript jquery jquery-validate forms asp.net-mvc-3
Maven
source share