jquery-validate

MVC3 Razor JQuery client side validation with an additional alert box

白昼怎懂夜的黑 提交于 2020-01-15 10:15:31
问题 I am being asked to create a login form that when the user input doesn't pass validation it pops an alert box. I have everything wire up using the model based validation. ex: public class LogonViewModel { [Required( ErrorMessage = "User Name is Required")] public string UserName { get; set; } [Required( ErrorMessage = "Password is required")] public string Password { get; set; } } I have a validation summary on the page: Html.ValidationSummary() I would like the summary to be on the page just

Can't get why URL custom validation method for jQuery validation plugin not working

泄露秘密 提交于 2020-01-15 09:43:30
问题 I'm trying to validate URL. I want to make these URLs pass the validation: www.site.com www.super.co.uk I'm checking my RegEx in this site - http://www.rubular.com/ Here is my RegEx: /^(https?:\/\/)?([\da-z\.-]+)\.([a-z\.]{2,6})([\/\w \.-]*)*\/?$/ It is working in Rubular site, but when I'm trying to use it in my custom jQuery validation Plugin method - it constantly tells me, that it is invalid: jQuery.validator.addMethod("complete_url", function(val, elem) { // if no url, don't do anything

Object doesn't support property or method 'valid'

天涯浪子 提交于 2020-01-15 07:44:30
问题 My code is throwing the following error: Object doesn't support property or method 'valid'. This is because the current form has no validation. That is OK. All I want is to check in advance whether or not I can apply the method valid to the current form to avoid the annoying JavaScript error. That is all I want. E.g. if(form.isValidatable()) form.valid() There is nothing wrong with the code. All I need is to know whether or not calling a method or property is going to throw an exception. form

jQuery - how to validate a date of birth using jQuery Validation plugin?

 ̄綄美尐妖づ 提交于 2020-01-15 05:18:31
问题 I want to validate an input ( date of birth ) using jQuery Validation plugin, but it must be in format "dd/mm/yyyy" and also not validate when the date of year is over 2002. So the date is valid when it's in this format "dd/mm/yyyy" and year over "2002" 回答1: I find the answer :D this is it. Thanks all $.validator.addMethod("birth", function (value, element) { var year = value.split('/'); if ( value.match(/^\d\d?\/\d\d?\/\d\d\d\d$/) && parseInt(year[2]) <= 2002 ) return true; else return false

jquery validate - replace commas in field before validation occurs

百般思念 提交于 2020-01-14 12:32:27
问题 It appears that even with the current validate plugin you can't have a comma in a value if you want to validate using min. I found on github where the patch was submitted several months ago (11 months) to modify the source .js file but it's still not in release. So instead of modifying my source .js file I'm trying to figure out how to replace the comma prior to validation. I tried something like this: $("#amount").blur(function(){ var val = $(this).val().replace(/\,/g,''); $(this).val( val )

jQuery validation fails when putting step=“1” in a “datetime-local” input type

对着背影说爱祢 提交于 2020-01-14 10:12:26
问题 I'm using https://jqueryvalidation.org/ form validation plugin When I put step="1" in a datetime-local input field to show seconds, if I'm validating that field with the plugin (just "required", for example), I get a javascript error saying "Step attribute on input type datetime-local is not supported". If I put this step="1" in a field that is not being validated, it works without problems. $("#testingform").validate(); <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery

jQuery: how to include validation in the ajaxForm function? [duplicate]

十年热恋 提交于 2020-01-14 03:33:08
问题 This question already has an answer here : .ajaxform not working inside the validation submitHandler? (1 answer) Closed 6 years ago . This question has been asked, but the answer wasn't confirmed. I tried it but it didn't work. So I would like to ask the same question again (Is this appropriate? If not, please advise me what to do). I have a form which needs to be validates and then submitted with ajaxForm (the form contains image and file data, so submission with .serialize() won't work).

Bootstrap-3: Input Group-Addon STRETCHES with jQuery Validation messages

試著忘記壹切 提交于 2020-01-14 02:51:11
问题 I'm using Twitter Bootstrap 3 with jQuery Validate plugin, but for some reason when the validation error message pops up it STRETCHES my Input Group-Addon box and the icon. NORMAL [NO VALIDATION] WITH VALIDATION Here's my Fiddle in case you want to solve the problem: My Fiddle I've tried multiple solutions on the web such as GitHub Issue of Input Addon and Input Addon issue on Stack Overflow But I can't seem to fix the problem, no matter what I try. Please let me know what do I have to do to

How do I include the field label in a jquery Validate error message

半世苍凉 提交于 2020-01-13 11:09:15
问题 I am displaying my jquery validate errors at the top of the page. I want to include the text value of the label associated with each invalid field next to each message. How is this done. Here is my jquery. $(document).ready(function(){ $("#reqAccount").validate({ errorClass: "error-text", validClass: "valid", errorLabelContainer: "#errorList", wrapper: "li ", highlight: function(element, errorClass, validClass) { $(element).addClass("error-input").addClass(errorClass).removeClass(validClass);

jquery validate: How to show and hide error summary?

☆樱花仙子☆ 提交于 2020-01-13 10:24:27
问题 I have implemented an error summary according to this example here: while I get it to display, I don't have a clue how to hide it once there are no errors remaining. I have fiddle here to demonstrate it: type in anything in either of the two fields, while the error messages go away, the summary still remains. There must be an event that I need to subscribe to, but I can't figure it out. $(document).ready(function () { var validator = validation_rules('#myform'); validator.form(); function