input check input box

js input validation input box (letters, numbers, symbols, Chinese)

<h1> js verify the contents of the input box </ h1 of>
<br />
<br />
 
only enter English
<input type = "text" onkeyup = "value = value.replace (/ [^ a-zA-Z] / G, '') ">
<br />
<br />
only enter English
<input type =" text "onkeyup =" value = value.replace (/ [^ \ a- \ z \ A- \ Z] / G, '') "
    onKeyDown =" fncKeyStop (Event) "onpaste =" return to false "
    the oncontextmenu =" return to false "/>
can not be pasted, and paste the pop-up menu is not right
<br />
<br />
numerical only:
<INPUT the onkeyup = "this.value = this.value.replace (/ \ D / G, '')"
    onafterpaste = "this.value = this.value.replace (/ \ D / G, '')">
< br />
<br />
only numeric, decimal point:
<INPUT name = ". price" type = "text"
    the onkeyup = "value = value.replace (/ [. ^ \ D \] / G, '')">
<br />
<br />
only numeric, decimal, underlined:
<INPUT name = ". price" type = "text"
    the onkeyup = "value = value.replace (/ [^ \ D \ ._] / G, '')" >
<br />
<br />
only enter alphanumeric:
<iNPUT the onkeyup = "value = value.replace (/ [\ W is] / G, '')"
    onbeforepaste = "clipboardData.setData ( 'text', . clipboardData.getData ( 'text') Replace (/ [^ \ D] / G, '')) ">
<br />
<br />
can input Chinese characters:
<iNPUT the onkeyup =" value = value.replace ( / [^ \ u4E00- \ u9FA5] / G, '') "
    onbeforepaste =" clipboardData.setData ( 'text', clipboardData.getData ( 'text'). Replace (/ [^ \ u4E00- \ u9FA5] / G, '')) ">
<br />
<br />
prohibit input method:
<INPUT type = "text" style = "IME-MODE: Disabled">
can not change the input method
<br />
<br />
Can input Chinese, English, numbers, symbols and @:.
<INPUT type = "text"
    the onkeyup = "value = value.replace (/ [^ \ A- \ Z \ A- \ Z0-9 \ u4E00- \ . u9FA5 \ @ \] / G, '') ">
<br />
<br />
not be empty:
<INPUT the onblur =" IF (this.value.replace (/ ^ + | + $ / G, '' ) == '') alert ( 'can not be empty!') ">
<br />
<br />
 

Guess you like

Origin blog.csdn.net/yijiupingfan0914/article/details/93741277