Input validation (non-plug-in)

Source: Internet
Author: User

<HTML>    <Head>        <MetaCharSet= "Utf-8"/>        <Scriptsrc= "Http://libs.baidu.com/jquery/2.0.0/jquery.min.js"></Script>    </Head><Body>    <fieldset>    <legend>Input limits</legend>    <Divstyle= "font-size:12px; color:red;">1. All input boxes are required; 2. Mailboxes and phones must be digital</Div>        <inputtype= "text"class= "IPT"Data-name= "Name"placeholder= "Name" /><BR/>        <inputtype= "text"class= "IPT"Data-name= "Gender"placeholder= "Gender" /><BR/>        <inputtype= "text"class= "IPT"Data-name= "Age"placeholder= "Age" /><BR/>        <inputtype= "text"class= "IPT"Data-name= "Phone"Data-type= "num"placeholder= "Phone" /><BR/>        <inputtype= "text"class= "IPT"Data-name= "Postcode"Data-type= "num"placeholder= "Postcode" /><BR/>                <Buttononclick= "tt ()">Submit</Button>    </fieldset>    <Scripttype= "Text/javascript">    //all input boxes must be filled        varIPT=$("input"); functiontt () { for (varI=0; I<ipt.length; I++) {                if(Ipt.eq (i). Val ()=="") {alert (Ipt.eq (i). attr ("Data-name")+"cannot be empty"); return false; }            }        }            //mailboxes and phones must be numbers [of course also can be set directly to input type number]        varIptnum=$("input[data-type= ' num ']"); Iptnum.blur (function(){            varNum=/^[0-9]*$/; if(!num.test ($ ( This) (Val ())) {Alert ("Please enter a number")                return false; }        })    </Script></Body></HTML>

Input validation (non-plug-in)

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.