You can only enter 1234567 in the specified text1 text box;
<Form ID = "form1" runat = "server">
<Div>
<Input id = "text1" type = "text" onkeyup = "checkinput ('20140901', event)"/>
</Div>
</Form>
<SCRIPT type = "text/JavaScript">
Function checkinput (codes, e) {// under Firefox ,,
VaR key1 = Window. event? E. keycode: E. Which; // Firefox obtains the ASC code pressed by the keyboard.
For (VAR I = 0; I <codes. length; I ++ ){
Alert (codes. charcodeat (I ))
If (key1 = codes. charcodeat (I) {// codes. charcodeat (I) is the ASC code for removing table I
Return true;
}
}
Document. getelementbyid ("text1 "). value = document. getelementbyid ("text1 "). value. substr (0, document. getelementbyid ("text1 "). value. length-1 );
Return false;
}
</SCRIPT>
<SCRIPT type = "text/JavaScript">
Function checkinput (codes ){
For (VAR I = 0; I <codes. length; I ++ ){
If (event. keycode = codes. charcodeat (I )){
Return true;
}
}
Document. getelementbyid ("text1 "). value = document. getelementbyid ("text1 "). value. substr (0, document. getelementbyid ("text1 "). value. length-1 );
Return false;
}
</SCRIPT>