jquery-validate

Jquery form validation on input type

蓝咒 提交于 2020-01-06 13:24:06
问题 I currently have a form which changes dynamically. I'm using all text inputs but they all should only accept numbers. $("#result-form").validate({ rules: { .text: { required: true, digits: true } }, messages: { .text:{ required: " Please enter a score!", digits: " Please only enter numbers!" } }, submitHandler: function(form) { form.submit(); } }); Currently i try to validate using the above but that doesn't work. Any ideas? 回答1: You cannot do it like this... $("#result-form").validate({

Validate Form preventing form submission

大兔子大兔子 提交于 2020-01-06 12:47:42
问题 I am using asp.net MVC 5 and trying to validate form on submission. everything works fine until i added the below line of code to validate form using ajax call. $('#signupform').validate({ submitHandler: function (form) { $.ajax({ type: 'POST', data: JSON.stringify({ type: "WhatsNew", code: $('#PrimaryCode').val() }), url: '@Url.Action("CheckCode", "Home")', dataType: 'json', contentType: 'application/json' }) .done(function (response) { if (response == 'success') { alert('success'); } else {

One validation message for multiple fields

被刻印的时光 ゝ 提交于 2020-01-06 10:22:22
问题 I'm having a problem with jQuery validation and could use some suggestions. Is there a way I can validate the three Phone Number fields in this form while only having one error message for the group? Any help is greatly appreciated. Form <form id="mForm" name="form"> <div class="field right"> <label class="labelStd" id="phoneNumber">Phone Number*</label> <input name="txtPhone1" type="text" maxlength="3" id="txtPhone1" class="small-phone" name="txtPhone1" Onchange="Tab(this, 'txtPhone2');" />

jQuery Validation plugin. Two custom rules not working

浪子不回头ぞ 提交于 2020-01-06 07:59:27
问题 I'm using jQuery validation engine and I have two custom rules that I need to use for one field. I've tried both of them one by one, they work fine. How do I attach both? class="validate[required,custom[OFS, onlyLattinLetters], maxSize[140]]" or class="validate[required,custom[OFS], custom[onlyLattinLetters], maxSize[140]]" doesn't work. 回答1: Instead of inline classes, have you tried declaring them within the plugin initialization function? $(document).ready(function() { $('#myForm').validate

jquery validation not working on an accordion

孤街醉人 提交于 2020-01-06 07:36:11
问题 sorry for the slightly general question here, but is there any reason why the jquery validate plugin would stop working on a form split across an accordion? Just to explain, and I'm sorry I can't give a URL to an example. I've got an asp.net form which is split across an accordion. The mandatory fields are only on the first accordion panel. When this panel is open the validation works. If any of the other panels are open it won't validate. For various strange reasons I'm calling the

jquery validation & id's ft numbers

怎甘沉沦 提交于 2020-01-06 05:09:07
问题 Hi I have a form which uses various numbers from salesforce e.g: Landing Page:<input id="00NF0000008Mrcm" maxlength="40" name="00NF0000008Mrcm" size="20" type="text" /><br> here is my jquery: $("#requestInfo").validate({ rules: { first_name: { required: true }, last_name: { required: true }, email: { required: true, email: true }, '00NF0000008Mrcm': { selectNone: true } }, messages: { first_name: 'Please enter your first name', last_name: 'Please enter your last name', email: 'Please enter

Preventing jquery validation on drop down bound to int?

天大地大妈咪最大 提交于 2020-01-06 04:29:05
问题 I have setup globalization on my web page and have this piece of code to validate numbers: $.validator.methods.number = function (value, element) { return !isNaN($.global.parseFloat(value)); }; But this now also validates drop down boxes where I bind to an Nullable eg: @Html.DropDownListFor(m => m.VendorId, Model.VendorList, "") which now does not validate properly. How can I prevent this validation on the client side? 回答1: Add data-val attribute: @Html.DropDownListFor(m => m.VendorId, Model

jQuery Validate plugin not working

点点圈 提交于 2020-01-06 03:36:05
问题 This is driving me nuts. The jQuery validation plugin doesn't seem to be doing anything at all. Here's the code: http://jsfiddle.net/pkyGf/ This is the validate code which is causing the error. <script> $(function(){ $('#purchase').validate({ rules:{ course:{ minLength:1 }, creditCard: { required: true, creditCard: true }, expMonth: { required: true, min: 1, max: 12, digits: true }, expYear: { required: true, min: 12, max: 60, digits: true } } }) }) </script> Thanks to anyone who can help.

.VALIDATE : CANCEL THE VALIDATION FOR A FIELD BASED ON REMOTE RESPONSE

≡放荡痞女 提交于 2020-01-05 12:30:34
问题 Consider the following code: $( document ).ready(function() { $("#register_employee_form").validate({ errorElement: "p", rules: { forename: "required", surname: "required", reportingto: { required : true, remote: { url: "ajax/error_checking/check_reporting_to.php", type: "post", data: { reportingto: function() { return $( "#reportingto" ).val(); // pass reportingto field } }, complete: function(response) { if (response.responseText == "false") { // CANCEL THE VALIDATION FOR THIS FIELD // HOW

.VALIDATE : CANCEL THE VALIDATION FOR A FIELD BASED ON REMOTE RESPONSE

我们两清 提交于 2020-01-05 12:30:06
问题 Consider the following code: $( document ).ready(function() { $("#register_employee_form").validate({ errorElement: "p", rules: { forename: "required", surname: "required", reportingto: { required : true, remote: { url: "ajax/error_checking/check_reporting_to.php", type: "post", data: { reportingto: function() { return $( "#reportingto" ).val(); // pass reportingto field } }, complete: function(response) { if (response.responseText == "false") { // CANCEL THE VALIDATION FOR THIS FIELD // HOW