Yilao Yong's solution is that textbox can only input numbers, Chinese characters, and letters.

Source: Internet
Author: User

Link: http://fus53.blog.163.com/blog/static/73588615200891712311647/

<Script language = JavaScript>
Function onlyeng ()
{
If (! (Event. keycode> = 65 & event. keycode <= 90 ))
Event. returnvalue = false;
}
Function onlynum ()
{
If (! (Event. keycode> = 48 & event. keycode <= 57) | (event. keycode> = 96 & event. keycode <= 105 )))
// Consider Number Key
Event. returnvalue = false;
}
Function isemail (stremail ){
If (stremail. search (/^ \ W + (-\ W +) | (\. \ W +) * \ @ [A-Za-z0-9] + ((\. |-) [A-Za-z0-9] + )*\. [A-Za-z0-9] + $ /)! =-1)
Return true;
Else
Alert ("oh ");
}
</SCRIPT>
<Div align = "center">
<Center>
<Table border = "1" width = "90%" cellspacing = "0" cellpadding = "0" style = "font-size: 12px "bordercolor =" #000000 "bordercolorlight =" #000000 "bordercolordark =" # ffffff ">
<Tr>
<TD width = "100%"> only Chinese characters: <input onkeyup = "value = value. replace (/[^ \ u4e00-\ u9fa5]/g, '')"> </TD>
</Tr>
<Tr>
<TD width = "100%"> Yes only English Character: <input onkeydown = "onlyeng ();"> </TD>
</Tr>
<Tr>
<TD width = "100%"> only numbers are allowed: <input onkeydown = "onlynum ();"> </TD>
</Tr>
<Tr>
<TD width = "100%"> Yes only English Letters and numbers: <input onkeyup = "value = value. replace (/[\ W]/g, '')" onbeforepaste = "clipboardData. setdata ('text', clipboardData. getdata ('text '). replace (/[^ \ D]/g, '')"> </TD>
</Tr>
<Tr>
<TD width = "100%"> verification email format: <input type = text onblur = isemail (this. Value)> </TD>
</Tr>
<Tr>
<TD width = "100%"> do not enter Chinese characters <input onpaste = "Return false;" style = "IME-MODE: Disabled; width: 400px" value = "I only accept English input! Thanks for corporation! "Name = textfield> </TD>
</Tr>

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.