Javascript Form Verification
When can I capture an error in form input?
1. Before an error occurs (keypress) 2. When the error occurs 3. After the error occurs
Generally, after the form data is input, the form is verified before the form is submitted.
Common form verification reduces whether the verification control is empty, and also includes whether the verification control is a number, whether it is a number in a series, whether it is a certain form of number, whether it is a character within a certain range, whether it is an email address or credit card number.
Empty or not
Function isempty (s)
{
If (S = NULL | S. Length = 0) return true;
// Regular Expression return! // S/. test (s );
}
Whether it is a number
Function isdigit (c)
{
Return (C> = "0") & (c <"9 "))
// Regular Expression return/^/d $/. Test (C );
}
Function isinteger (field)
{
VaR S = field. value;
If (! (/^ -? /D + $/. test (s )))
Return false;
Return true;
}
Whether the button is a number
Function isnumberinput (field, event)
{
Var key, keychar;
If (window. Event) Key = Window. event. keycode;
Else if (event) Key = event. Which;
Else return true;
// Check for special characters
If (Key = NULL) | key = 0 | key = 8 // key = 13 | key = 27)
Reutrn true;
// Check whether it is a number
Keychar = string. fromcharcode (key );
If (/^/D/. Test (keychar)
{
Window. Status = '';
Return true;
}
Else
{
Window. Status = "The control accepts numbers ";
Return false;
}
}
XML Basics
XML declarations include version, standalone, and encoding)
<? XML version = "1.0" standalone = "yes" encoding = "gb2312"?>
XML Naming rules:
1. the name can contain letters, numbers, and other letters.
2. The name cannot start with a number or underline
3. The name cannot start with the letter XML (or XML ...).
4. The name cannot contain spaces or colons.
All texts in the CDATA segment are pure character data and are not interpreted <! [CDATA [...]>
The property command must comply with the following rules:
The attribute name starts with a letter or underscore and cannot contain spaces.
The same element cannot have two attributes with the same name, that is, the same attribute can only appear once in one element.
Attribute names are case sensitive.
You cannot use any form of attribute prefixed with "XML ".
The attribute value is a series of characters defined by quotation marks.
XML Technical System
Document Description and Verification Technology (DTD/Schema)
Document Conversion Technology (XSL/XSLT)
Document Query Technology (XPath/XQuery)
Document Programming Interface (xml dom/SAX)
Document link and positioning technology (xlink/xpointer)
XML application scope
Data Exchange web service content management Web Integration System Configuration
XML with complete structure
1. the attribute has an XML declarative statement.
2. There must be a public root element.
3. Mark case sensitive
4. attribute values are enclosed in quotation marks.
5. tag pairs
6. Mark to close
7. Correct element nesting