Client programming-JavaScript (5) and XML Basics

Source: Internet
Author: User
Tags cdata

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.