jQuery Validate Required Select

An easier solution has been outlined here: Validate select box Make the value be empty and add the required attribute <select id=”select” class=”required”> <option value=””>Choose an option</option> <option value=”option1″>Option1</option> <option value=”option2″>Option2</option> <option value=”option3″>Option3</option> </select>

jQuery Validation plugin: disable validation for specified submit buttons

You can add a CSS class of cancel to a submit button to suppress the validation e.g <input class=”cancel” type=”submit” value=”Save” /> See the jQuery Validator documentation of this feature here: Skipping validation on submit EDIT: The above technique has been deprecated and replaced with the formnovalidate attribute. <input formnovalidate=”formnovalidate” type=”submit” value=”Save” />

jQuery Validate – Enable validation for hidden fields

The plugin’s author says you should use “square brackets without the quotes”, [] Release: Validation Plugin 1.9.0 Release: Validation Plugin 1.9.0: “…Another change should make the setup of forms with hidden elements easier, these are now ignored by default (option “ignore” has “:hidden” now as default). In theory, this could break an existing setup. In … Read more

jQuery validate: How to add a rule for regular expression validation?

Thanks to the answer of redsquare I added a method like this: $.validator.addMethod( “regex”, function(value, element, regexp) { var re = new RegExp(regexp); return this.optional(element) || re.test(value); }, “Please check your input.” ); Now all you need to do to validate against any regex is this: $(“#Textbox”).rules(“add”, { regex: “^[a-zA-Z’.\\s]{1,40}$” }) Additionally, it looks like … Read more

jQuery Validate Plugin – How to create a simple custom rule?

You can create a simple rule by doing something like this: jQuery.validator.addMethod(“greaterThanZero”, function(value, element) { return this.optional(element) || (parseFloat(value) > 0); }, “* Amount must be greater than zero”); And then applying this like so: $(‘validatorElement’).validate({ rules : { amount : { greaterThanZero : true } } }); Just change the contents of the ‘addMethod’ … Read more

jQuery validation: change default error message

Add this code in a separate file/script included after the validation plugin to override the messages, edit at will 🙂 jQuery.extend(jQuery.validator.messages, { required: “This field is required.”, remote: “Please fix this field.”, email: “Please enter a valid email address.”, url: “Please enter a valid URL.”, date: “Please enter a valid date.”, dateISO: “Please enter a … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)