form selector
: Input ( matches all input,textarea,Select , and button element ) |
|
: Text ( matches all single-line text boxes ) |
|
:p Assword ( match all password boxes ) |
|
: Radio ( matches all individual buttons ) |
|
: CheckBox ( matches all check boxes ) |
|
: Submit ( match all submit buttons ) |
|
: Image ( matches all image fields ) |
|
: Reset ( matches all reset Buttons ) |
|
: Button ( matches all buttons ) |
|
: File ( matches all file domains ) |
|
: Hidden ( matches all invisible elements, or elements of type hidden ) |
|
Form Attribute Filter
Grammar |
Describe |
Instance |
|
:enabled |
Match all visible elements |
|
|
:Disabled |
Match all unavailable elements |
|
|
:checked |
Match all selected elements (check box, single button, option in select) |
|
|
:selected |
Match all of the selected option elements |
|
|
|
|
|
|
Forms validation common methods and events
event:onblur: loses focus, triggers when cursor leaves a text box
Onfocus: Gets the focus, which is triggered when the cursor enters a text box
method:Blur () move focus away from text field
Focus () sets the focal point in the text field, which is to get the cursor
Select () Gets the contents of the Text field, highlighting the contents of the lost region
Text input Hint Effect example
$( " Myform:text " ). focus (function () {
If ($ (this). val () = =" Please enter the correct e-mail address ") {
$ (this). Val ("");
$ (this). CSS ("border","1px solid #ff0000" );
}
})
what is a regular expression
A regular expression is an object that describes a character pattern, which is made up of special symbols that are the same wildcard characters that SQL Server has learned
RegExp objects are abbreviations for Regular expression ( regular Expressions ) , authentication (e-mail address, phone number, social security number, and other strings)
There are two forms of defining a regular expression: one is normal and the other is the way the constructor functions
Normal way:
Var reg=/ expression / Additional parameters
Additional parameters have three parameters:
G: represents the ability to make a global match
I: representing case-insensitive matching
M: represents the ability to make multi-line matches
constructor function
Var reg =new RegExp (" expression ", " additional parameters ")
The pattern of expression is divided into simple mode and compound mode
characters commonly used characters for regular expressions
- /.. / represents the start and end of the pattern
- ^ start of matching string
- $ Match end of string
- \s any whitespace characters
- \s any non-whitespace characters
- \d matches a numeric character equivalent to [0-9]
- \d Any character other than a number, equivalent to [^0-9]
- \w matches a number, underscore, or alphabetic character, equivalent to [a-za-z0-9]
- \w any non-word character, equivalent to [^a-za-z0-9]
- . any character other than a line break
repeating characters for regular expressions
N Match Previous Item N Times
{N,} Match Previous Item N Times , or multiple times .
{N,m} match the previous item at least N times, but not more than m Times
* match the previous item 0 times , or multiple times, equivalent to {0,}
+ match the previous item 1 times , or multiple times, equivalent to {1,}
? Matches the previous item 0 times , or 1 times, which means the previous item is optional, equivalent to {0,1}
Web front-end form validation