using a custom jQuery validation class

I have some custom validation I'd like to do with jQuery. jQuery validation comes out of the box with a 'required' class. This means that I can have a script declaring

$('form').validate()

and the next textbox will validate correctly, based on the class 'required' I add to it:

<input type="text" value="" name="flowstatus" id="flowstatus" class="required">

My new validation rule is: the text in a textbox should be between 15 and 50 chars long. Is there a way to create my own custom rule/class to implement something like

<input type="text" value="" name="flowstatus" id="flowstatus" class="from15to50">

Note: This is NOT what I need:

('form').validate({
    rules: {
        flowstatus: {required: true, minlength: 15, maxlength: 50}
}}); 

This last script is too tightly coupled to the fields I want to validate.

Answers


I'm pretty sure that you can add an attribute to the desired element defining its min and max lengths. Something like:

<input type="text" value="" name="flowstatus" id="flowstatus" class="required" minlength="15" maxlength="50">

I'm not quite sure about the custom class solution, however.


Need Your Help

I keep getting exception in thread “main” java.util.NoSuchElementException for arrayList

java arraylist

Whenever I run my code which is supposed to analyze a text input I get the following output. The other methods used to count words and alphanumeric digits works but the other method which is supposed

MySQL decimal fields returned as strings in PHP

php mysql string casting decimal

By default mysqli returns all values as strings, the MYSQLI_OPT_INT_AND_FLOAT_NATIVE option allows you to convert ints and floats to their appropriate types. Though this does not affect decimal fie...