Prototype.js is the foundation of all
Validation.js Real Validation Framework file, Badqiu added a lot of good features on the original basis
1: Refer to JS file
<script>"prototype.js"
type="text/javascript">
</script>
<script>"validation.js"
type="text/javascript">
</script>
2: Referencing CSS files
You can join the style declaration in Style_min.css, or you can introduce the style declaration in STYLE_MIN.CSS into your frame js file.
3:hellow World
In Badqiu extensions, if an element in a form is validated to add a class= ' required-validate ' to the form, the frame is automatically bound at load
All the fields to validate.
XML code
<!-- 为form增加required-validate class,标识需要验证form -->
<form id='helloworld' action="#" class='required-validate'>
helloworld:<!--</span-->br>
<!--通过class添加验证: required表示不能为空,min-length-15表示最小长度为15 -->
<textarea name='content' class='required min-length-2'><!--</span-->textarea><!--</span-->br>
<input type='submit' value='Submit'/>
<input type='reset' value='Reset'/>
<!--</span-->form>
Declare the restricted condition of the checked domain by the class attribute in the domain to be checked, for example, the class= ' required min-length-2 above indicates that this is a non-null, and the field with a minimum length of 2 is automatically checked when the edit field loses focus, and if the input does not meet the above conditions, An error message is generated.
4: Check the rule description
Required--Non-airspace
Validate-number--An effective number
Validate-digits--can contain only [0-9] any number
Validate-alpha--Only the letters [A-ZA-Z]
Validate-alphanum--Only a combination of letters and numbers
Validate-date--Only the date.
Validate-email--It can only be a valid email.
Validate-url--can only be a valid URL address
Validate-date-au--Date must be in the form of dd/mm/yyyy
Validate-one-required-At least one is selected, such as a set of CheckBox, RadioButton, which are best included in a div and span
VALIDATE-DATE-CN--Date must be in the form of YYYY/MM/DD
Validate-integer--only integers, can have positive and negative numbers
Validate-chinese--can only be Chinese
VALIDATE-IP--A valid IP address
Validate-phone--effective telephone (for China only)
Validate-mobile-phone--Effective mobile phone number, in the Badqiu version only validated 135, the need to improve
validate-equals-$otherInputId--Must be equal to an input field such as Validate-equals-otherinputid (where $some represents a specific value)
less-than-$otherInputId--less than an input field Less-than-otherinputid (where $some represents a specific value)
great-than-$otherInputId--greater than an input field Less-than-otherinputid (where $some represents a specific value)
min-length-$number-The minimum length is $number (where $some represents a specific value)
max-length-$number-The maximum length is $number (where $some represents a specific value)
validate-file-$type 1-$type 2-$typeX--file input must be a declared $type1--one of the $typeX
validate-float-range-$minValue-$maxValue-must be a floating-point number $minvalue to $maxvalue
validate-int-range-$minValue-$maxValue-Must be an integer $minvalue to $maxvalue
validate-length-range-$minLength-$maxLength-the length of the input string must be between $minlength and $maxlength
max-value-$number--The maximum value of the input field is $number
min-value-$number--The minimum value of the input field is $number
validate-pattern-$patternAttributes--Verifying the correctness of an input field by customizing pattern
Validate-ajax--Validate input fields with Ajax