jquery-validate

Jquery validate year not greater than today

不羁岁月 提交于 2019-12-25 17:45:25
问题 I'm trying to create a method for jquery validate plugin to validate if the year entered in a text field is not greater than today's year, but I can't tell why it is not working. Any help is much appreciated. My script: $.validator.addMethod("checkYear", function(value, element) { var year = $("#dateBirthYYYY").val(); var myYear = new Date(); myYear.setFullYear(year); var currentYear = new Date(); currentYear.getFullYear(); return currentYear > myYear; }, "Invalid year"); 回答1: It should be

Jquery Unobstrusive validation show errors manually for Valid

回眸只為那壹抹淺笑 提交于 2019-12-25 17:18:57
问题 I have added errors manually to my input using the link in here Here and the example in Here but when I try $("#myshowErrors").valid() after I added the errors it becomes true? here is my code var validator = $( "#myshowErrors" ).validate(); validator.showErrors({ "firstname": "I know that your firstname is Pete, Pete!" }); I am not able to make the client validation fail. How can I make form.valid() to return false ? I don't want to make form.valid()=false; manually I want that to be taken

form post is omitted after jquery validation is completed [duplicate]

孤街浪徒 提交于 2019-12-25 16:39:33
问题 This question already has an answer here : jquery validator form: how to access form action, after the completion of a remote email validation (1 answer) Closed 4 years ago . UPDATE: Closing this thread since issue was the remote post was interfering with form post. More can be found at this new post Before I add validation, the form is posting correctly. Got this form, which validates the email and after it is done the form completes the onsubmit javascript function but the data of the form

Trigger modal if submitting valid form in ASP.NET MVC 5 application?

情到浓时终转凉″ 提交于 2019-12-25 11:57:06
问题 I am creating an ASP.NET MVC 5 application. There is a long wait time between the user clicking the "submit" button and the next page to load, so I would like a "please wait" modal to pop up only if the user has submitted a valid form. I have tried the following code, which causes the modal to pop up no matter if the form is valid or not: $('form').submit(function () { $('#waitingModal').show(); }); My application utilizes the jQuery Validate plugin and unobtrusive validation which both came

jquery Validate not validating input in IE 8

一曲冷凌霜 提交于 2019-12-25 08:59:36
问题 I am using jquery validation and it is not catching instances where the validation conditions are not met? This is curious to me, partly, because it was working before (I am using IE 8 in compatibility mode now, would that affect something?)... There don't seem to be any compilation exceptions off the top of my head? Does where I import the jquery validation src file affect how it works??? Here is my code... $("#temp1").validate({ rules: { HospitalFinNumber: { required: true, minlength: 6 },

jQuery Setting a validation error box with two classes

喜夏-厌秋 提交于 2019-12-25 08:35:13
问题 I have an with my code and I have one particular textarea that I am using the main .error class and another .textAreaError that places the error box were I want it but I am unsure how I would configure the textarea error to load in this specific box. From a previous question I was given the following jQuery line function(error, element) { error.appendTo(element.siblings("label")); } but I am unsure how to work it into the code below. jQuery: jQuery(document).ready(function() { //Home

JQuery validation: Add method for checking duplicate values in a text-box

本小妞迷上赌 提交于 2019-12-25 07:36:32
问题 Below validation method will check for duplicate values in all textBoxes having class name checkForDuplicate $.validator.addMethod("checkForDuplicate", function(value, element) { var textValues = []; $("input.validateLocation").each(function() { if($(this).val() !== ""){ var doesExisit = ($.inArray($(this).val(), textValues) === -1) ? false : true; if (doesExisit === false) { console.log("adding the values to array"); textValues.push($(this).val()); console.log(textValues); } else { console

Passing data to server in remote validation

你说的曾经没有我的故事 提交于 2019-12-25 07:13:45
问题 Using jquery validation with remote on one of the fields. How do I send the data to the server of what the user entered into the field? rules: { "profile.userId": { required: true, minlength: 8, remote: { url: "/checkUniqueUserId", dataType: "json", type: "POST", data: {userId : '???'} } } How do I extract the entered value in the input field? I've tried: $("#userId").val() userId profile.userId $(this).val() Any suggestions? This is in my jsp: <div class="control-group"> <div class="form

Select class control-group where none of its children are span.error

纵然是瞬间 提交于 2019-12-25 06:55:06
问题 I am working with twitter bootstrap and the jquery validate plugin I have a form row that looks like: <div class="form_row" > <div class="control-group"> <label class="control-label" for="input01">home phone</label> <div class="controls"> <input type="number" class="span4" class="input-xlarge" id="home_phone" name="home_phone" value="<?php echo $this->property->home_phone ?>" rel="popover" data-content="Re-enter your home phone." data-original-title="homephone" > <input type="number" class=

jquery validation plugin - file upload

我的未来我决定 提交于 2019-12-25 06:49:30
问题 I am using jquery validation plugin for validating my form. I have one file field in form for uploading documents. <input type="file" name="policyBriefFiles" id="policyBriefFiles" multiple="multiple"> Here is my validation code for this field. policyBriefFiles: { extension:'xlsx,pdf', filesize: 2097152, }, Now I want users to select maximum two files, but with multiple attribute specified with file user can select any number of files. How do I restrict users to select maximum two files and no