Script Javascript :
<script type="text/javascript">
function checkNumber(val)
{
var strPass = val.value;
var strLength = strPass.length;
var lchar = val.value.charAt((strLength) - 1);
var cCode = CalcKeyCode(lchar);
/* Check if the keyed in character is a number
do you want alphabetic UPPERCASE only ?
or lower case only just check their respective
codes and replace the 48 and 57 */
if (cCode < 48 || cCode > 57 )
{
var myNumber = val.value.substring(0, (strLength) - 1);
val.value = myNumber;
}
return false;
}
</script>
function checkNumber(val)
{
var strPass = val.value;
var strLength = strPass.length;
var lchar = val.value.charAt((strLength) - 1);
var cCode = CalcKeyCode(lchar);
/* Check if the keyed in character is a number
do you want alphabetic UPPERCASE only ?
or lower case only just check their respective
codes and replace the 48 and 57 */
if (cCode < 48 || cCode > 57 )
{
var myNumber = val.value.substring(0, (strLength) - 1);
val.value = myNumber;
}
return false;
}
</script>
panggil function nya pada script HTML :
<input type="text" name="emplcode" size="10" id="emplcode" onKeyUp="checkNumber(form_name.emplcode);">
No comments:
Post a Comment