jquery-validate

How can I show errors in jQuery validation?

淺唱寂寞╮ 提交于 2019-12-21 04:35:11
问题 Do we have any function which returns all the error messages while validating a form? I have tried using the defaultshowerros() function but it returns the error message for the element it is currently validating. How can I get all the error messages of the whole form? 回答1: If you store a reference to the validator, for example: var validator = $("form").validate(); You can call .errors() or .invalidElements() at any time on it, for example: var errors = validator.errors(); //get the error

How can I add callbacks to jquery validation (when used in MVC 2)

ぐ巨炮叔叔 提交于 2019-12-21 04:13:21
问题 I'm using jquery for validation in my MVC2 web app (as described here) and I'd like to wire up some callbacks that the jquery validation plugin supports, like invalidHandler, etc. I can manually edit the MicrosoftMvcJQueryValidation.js and add my callbacks (in __MVC_EnableClientValidation, in the options variable) but I was looking for a better approach since that file is used repeatedly and I don't want to have to create one-off copies. A way to manually add an invalidHandler (etc) callback

How can I add callbacks to jquery validation (when used in MVC 2)

拜拜、爱过 提交于 2019-12-21 04:13:07
问题 I'm using jquery for validation in my MVC2 web app (as described here) and I'd like to wire up some callbacks that the jquery validation plugin supports, like invalidHandler, etc. I can manually edit the MicrosoftMvcJQueryValidation.js and add my callbacks (in __MVC_EnableClientValidation, in the options variable) but I was looking for a better approach since that file is used repeatedly and I don't want to have to create one-off copies. A way to manually add an invalidHandler (etc) callback

Try to set custom validation message with jQuery Remote

你离开我真会死。 提交于 2019-12-21 04:12:13
问题 I have the a form with the following validation setup: $('#form').validate({ onfocusout: false, onkeyup: false, onclick: false, success: function (){ $('#username').addClass('input-validation-confirmation'); } }); $('#username').rules("add", { onfocusout: false, onkeyup: false, required: true, email: true, remote: { url: function, type: 'GET', dataType: 'json', traditional: true, data: { username: function () { return $('#username').val(); } }, dataFilter: function (responseString) { var

jQueryValidate - Required field - depends doesn't work

安稳与你 提交于 2019-12-21 03:57:26
问题 With jQueryValidate, I'm trying to make a field required only if another specific field is empty. So, after searching on the Internet, I did this : rules: { marque: { required: { depends: function() { if (($('#add_marque').val() == "Ajouter une marque" && $('#marque').val() == -1) || ($('#add_marque').val() == "" && $('#marque').val() == -1)) { return true; } else { return false; } } } } } Unfortunately, it doesn't work. But, if I do this : depends: function() { if (($('#add_marque').val() ==

“this[0] is undefined” message using jQuery validate plugin

做~自己de王妃 提交于 2019-12-21 03:43:10
问题 I've started to use the jQuery validate plugin. I was having a few issues with the display of the error messages and wanted to create a test page where I could experiment with a few things. Despite the same setup working for me yesterday, I'm now getting the follwing message: this[0] is undefined looking at the jQuery code, it fails in the following section (specific line highlighted): valid: function() { if ( $(this[0]).is('form')) { return this.validate().form(); } else { var valid = true;

How to manually invalidate fields after AJAX call with jQuery validate

六眼飞鱼酱① 提交于 2019-12-21 03:21:35
问题 Note: the below code is just for demonstration and I am using jQuery and jQuery validate plugin. Suppose I have a form with two fields (email and inventory number): <form action="/something" method="post" id="demoForm"> Inventory No: <input type="text" class="required" name="inventory_no" /> Email: <input type="text" class="required" name="email" /> <input type='submit' value='submit' /> </form> Binding plugin to form: jQuery(function(){ jQuery('#demoForm').validate(); }); //handle user

jquery validate add method to validate datetime

不打扰是莪最后的温柔 提交于 2019-12-20 20:59:07
问题 I'm using a datetimepicker plugin that I found here which works quite well. The only problem now is that it breaks the standard date validation included with the jquery validation plugin because of the added time on the end of the string in the input box. Here is what I have so far in a demo. I added a validation method that checks if the value is a date, but it doesn't accept the time. I need help with writing the custom validation method. How do I split the date and time string and then

MVC : How to enable client side validation on hidden fields

北慕城南 提交于 2019-12-20 17:24:33
问题 @Scripts <script src="@Url.Content("~/Scripts/jquery-1.7.1.min.js")"></script> <script src="@Url.Content("~/Scripts/jquery.validate.js")"></script> <script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.js")"></script> @View @using (Html.BeginForm("TestModelState", "RandD", FormMethod.Post, new {id="form123" })) { @Html.TextBoxFor(x => x.htmlText, new { style="display:none"})<br /> @Html.ValidationMessageFor(x => x.htmlText) <div> @Html.TextBoxFor(x => x.Uprop1)<br /> @Html

jQuery Validation Plugin: How can I force validation on previously valid fields?

我的未来我决定 提交于 2019-12-20 12:32:53
问题 I'm using jQuery Validation plugin to validate a form. Do you know how to force revalidation on previously successful fields? I have tried the .form function using the following check (this is performed after the user clicks 'submit'): if ($('#form1').validate().form()==false) { formValid = false; } However, it appears that the code above does not retry validation so fields that are already successfully validated (ie have tick next to them) are not checked again. The reason for wanting to