Powerful and convenient form universal detection JS is good

Source: Internet
Author: User

<! DOCTYPE html PUBLIC "-// W3C // dtd xhtml 1.0 Transitional // EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <ptml xmlns = "http://www.w3.org/1999/xhtml"> <pead> <meta http-equiv =" content-Type "content =" text/html; charset = gb2312 "/> <title> untitled document </title> <style type =" text/css "> </style> </pead> <body> <table width = "80%" border = "0" align = "center" cellpadding = "5" cellspacing = "1" bgcolor = "# CCCC CC "> <tr> <td height =" 100 "valign =" top "bgcolor =" # FFFFFF "> JS common form Input detection block (supported by IE) customize the six new attributes of each Input (any attributes can be omitted) // custom attribute explanation (supported by IE): // ii_chname: chinese name of the Data // ii_minsize: indicates the minimum length allowed for input, in bytes // ii_maxsize: indicates the maximum length allowed for input, in bytes // ii_type: restrict the input data types, including EN (English), CN (Chinese), NUM (real number), INT (integer), DATE (short DATE), and EMAIL (EMAIL) CARD (id card), URL (URL), IP (IP address), ID1 (English account), ID2 (Chinese and English account) // ii_null: indicates whether the input value can be blank. If yes, It is null. // Ii_compare: whether the bitrate is the same as the value of an item (ID). There are two detection methods. One is to add onBlur = "verifyInput (this);" event to the Input, instant detection prompt 2: onsubmit = "return chkFromAll (this);" in Form. You can use this method only after submitting the file. You can save the script part on this page as Form_Common.js, this solution solves most of the form detection problems and has nothing to do with the background programming language. It accelerates the efficiency of background programming and enables you to focus more on background writing. :) due to the well-known reasons, FF and so on seem to not support custom attributes, and there is no solution at the moment (despise it ). To be compatible, you can use the document by writing the chkfrom function. getElementById ('id') and JS file functions to detect, it will speed up the efficiency of this is only my web programming efficiency tool (Eff. studio). If you have a friend who needs it, I will disclose that the table directly generates a form tool and automatically creates a background (including adding, listing, editing, and deleting) class (only ASP edition for work) will greatly accelerate the design efficiency ~~~ Yes ~ (Reprinting is supported, copying is not studied, and the author information is retained) </td> </tr> </table> demo form: </body> </ptml>
[Ctrl + A select all Note: If you need to introduce external Js, You need to refresh it to execute]

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.