Style = "ime-mode: Disabled ;"
1. Use js to convert the fullwidth to halfwidth (punctuation cannot be converted)
<Input type = "text" size = "10" maxlength = "10"
Onkeyup = "javascript: var T =''; with (this. value) {for (VAR I = 0; I <length; I ++) T + = (65296 <= charcodeat (I) & charcodeat (I) <= 65305 )? String. fromcharcode (charcodeat (I)-65248): charat (I);} This. value = T ;"
/>
<Br>
<Br>
2. Use js to convert the fullwidth into a halfwidth Function
<Input name = "N" type = "text" id = "N" onkeyup = "ctoh (this);"/>
<SCRIPT>
Function ctoh (OBJ)
{
VaR STR = obj. value;
VaR result = "";
For (VAR I = 0; I <Str. length; I ++)
{
If (Str. charcodeat (I) = 12288)
{
Result + = string. fromcharcode (Str. charcodeat (I)-12256 );
Continue;
}
If (Str. charcodeat (I)> 65280 & Str. charcodeat (I) <65375)
Result + = string. fromcharcode (Str. charcodeat (I)-65248 );
Else result + = string. fromcharcode (Str. charcodeat (I ));
}
OBJ. value = result;
}
</SCRIPT>
<Br>
<Br>
3. Use js to convert the fullwidth to halfwidth (only numbers, decimal points, and negative numbers are allowed)
<Input
Onkeypress = "Var K = event. keycode; return K >=48 & K <= 57 | K = 46 | K = 45"
Onpaste = "return! ClipboardData. getdata ('text'). Match (/\ D /)"
Ondragenter = "Return false" style = "ime-mode: Disabled"
>
<Br>
<Br>
4. Convert the fullwidth to halfwidth using JS (only numbers are allowed)
<Input
Onkeypress = "Var K = event. keycode; return K >=48 & K <= 57"
Onpaste = "return! ClipboardData. getdata ('text'). Match (/\ D /)"
Ondragenter = "Return false" style = "ime-mode: Disabled"
>
<Br>
5. full-width characters are not allowed.
<Input name = "cardid" onkeyup = "quanjiao (this);">
<Script language = "JavaScript">
Function quanjiao (OBJ)
{
VaR STR = obj. value;
If (Str. length> 0)
{
For (VAR I = Str. Length-1; I> = 0; I --)
{
Unicode = Str. charcodeat (I );
If (UNICODE> 65280 & Unicode <65375)
{
Alert ("full-width characters are not allowed. Please enter half-width characters ");
OBJ. value = Str. substr (0, I );
}
}
}
}
</SCRIPT>