jquery-validate

JQuery Validation and Bootstrap 3 for same form-group

爷,独闯天下 提交于 2019-12-23 10:13:06
问题 I'm having a question regaring "has-error" class and the complex object. Basically for single simple type it works pretty well but for a complex object it doesnt. I have following code: My validation: public static MvcHtmlString ValidationErrorFor<TModel, TProperty>(this HtmlHelper<TModel> htmlHelper, Expression<Func<TModel, TProperty>> expression, string error) { if (HasError(htmlHelper, ModelMetadata.FromLambdaExpression(expression, htmlHelper.ViewData), ExpressionHelper.GetExpressionText

Trigger jQuery form validation only if form has already been submitted?

▼魔方 西西 提交于 2019-12-23 10:09:25
问题 Unobtrusive validation is based on the idea that you don't do form validation until the form has been submitted by the user; once that's happened, if something is invalid on the form, then each field is immediately validated once the user has changed it. What I want to do is trigger validation on a form element "unobtrusively" - that is, only validate the form element if the user has already tried to submit the form. So I can trigger the validation of an element (I do it when a certain

Customising event delegates in the jQuery validation plug-in

馋奶兔 提交于 2019-12-23 09:16:51
问题 I am currently setting up the jQuery validation plug-in for use in our project. By default, there are some events automatically set up for handling. I.e. focus in/out, key up events on all inputs fire validation. I want it to only fire when the submit button is clicked. This functionality seems to be in-built into the plug-in, which is making it difficult to do this (without modifying the plug-in code, Not What I Want To Do). I have found the eventDelegate function calls in the plugin code

jquery validate - valid if hidden field has a value

喜欢而已 提交于 2019-12-23 07:21:42
问题 I need to validate a field based on the value of a hidden field. I tried this custom rule: jQuery.validator.addMethod("cityselected", function() { if ($('#featureID').val() == "") return false; else return true; }); cityselect: { required: true, cityselected: true }, featureID is a hidden input which I need to check has a value. This doesnt seem to work though. Any ideas? 回答1: Add the class "required" to the hidden input. 回答2: If your plugin version is greater than 1.9, you'll have to

jquery validate - valid if hidden field has a value

被刻印的时光 ゝ 提交于 2019-12-23 07:21:19
问题 I need to validate a field based on the value of a hidden field. I tried this custom rule: jQuery.validator.addMethod("cityselected", function() { if ($('#featureID').val() == "") return false; else return true; }); cityselect: { required: true, cityselected: true }, featureID is a hidden input which I need to check has a value. This doesnt seem to work though. Any ideas? 回答1: Add the class "required" to the hidden input. 回答2: If your plugin version is greater than 1.9, you'll have to

How to not display error element as label with jquery.validation plugin

我与影子孤独终老i 提交于 2019-12-23 07:17:31
问题 Okay guys, I have read through all the other posts and question on jQuery Validation plugin and they don't seem to have what I'm looking to do. I would like to have the display error not show with message but just create a red border around the input field instead. Here is just some of the form: <form id="donate_form" name="checkoutForm" method="post"> <label class="desc" id="title0" for="billing_name_first"> Name <span id="req_1" class="req">*</span> </label> <div> <span class="left"> <input

How to not display error element as label with jquery.validation plugin

我只是一个虾纸丫 提交于 2019-12-23 07:17:05
问题 Okay guys, I have read through all the other posts and question on jQuery Validation plugin and they don't seem to have what I'm looking to do. I would like to have the display error not show with message but just create a red border around the input field instead. Here is just some of the form: <form id="donate_form" name="checkoutForm" method="post"> <label class="desc" id="title0" for="billing_name_first"> Name <span id="req_1" class="req">*</span> </label> <div> <span class="left"> <input

TypeError: validator is undefined in jquery.validate.js [duplicate]

爱⌒轻易说出口 提交于 2019-12-23 06:48:29
问题 This question already has answers here : jQuery validation plugin error: TypeError: validator is undefined (13 answers) Closed 4 years ago . I have following form. once I click that Go to Next Section Button I can direct to next section in this form. Here the whole code for this view and this the Layout file for that view page But now Once I click I'm not getting any response and I cannot goto next page I'm getting following error.But this error occur in Firefox only , once I change debugging

Using jQuery Validate's invalidHandler event

孤街浪徒 提交于 2019-12-23 05:58:20
问题 I need to add a class to div that is wrapped around the select element upon validation. $("#Form").validate({ invalidHandler: function (form, validator) { $("[id$='_DropDownList']").each(function () { // How do I figure out if $(this) is valid or invalid? // Add the class below if invalid. $(this).parent().addClass("error"); }); } }); 回答1: You can use the .valid() method, like this: $("#Form").validate({ invalidHandler: function (form, validator) { $("[id$='_DropDownList']").each(function ()

jquery validate not working on multiple form

…衆ロ難τιáo~ 提交于 2019-12-23 05:46:06
问题 Jquery validate works fine for webpage with single form. However, when i call the form through jquery and display in jquery-ui dialog the validation does not work anymore. I am calling the contact us from from the main page. In the main page another form exist use for searching. The code is given below. $("#contactus").live('click',function(){ $.get('/gordon/contacts/sendemail',function(result){ $('#popupinfo').html(result); $( "#popupinfo" ).dialog( "option", "title", 'Contact Us' ); $( "