Web page embedded javascript validation null, Chinese characters, letters, digital length input

Source: Internet
Author: User
Javascript| Chinese Characters | Web page

First, verify the form:

<form action= "orginsert.jsp" name= "F1" language= "JavaScript" >

<input type= "text" name= "dep"/>

Second, we write JavaScript to embed HTML in the following code:

<script language= "JavaScript" >

function F1_submit () {

if (document.f1.dep.value== "")

{

Alert ("Sorry, department name no input!")

Document.f1.dep.focus ()

return False

}

if (document.f1.dep.value.length>12)

{

Alert ("Sorry, the name of the incoming section is long!")

Document.f1.dep.focus ()

return False

}

if (document.f1.dep.value!= ' AB ')

NULL is NULL to judge num Digit AB letter chs Chinese character bit number

{

Alert ("Sorry, please enter the name of the door is called" Hans!)

Document.f1.dep.focus ()

return False

}

}

</script>

Third, I have written a simple analysis of JavaScript, note that the matching JavaScript statement does not have a semicolon!

Today, the organization architecture module, including a thorough page art, and Drop-down menu for the dynamic Department display. After writing, forget the user input verification, remember, as long as the user input, you need to verify:

1. Null or void

2. Are Chinese characters, numbers, letters

3. Include Special HTML characters

Even mail address verification, call number verification, fixed format verification, and so on ... As if using regular expressions, this is also very important, later to learn.



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.