docock
02-26-2007, 11:04 AM
NEVER MIND, problem is solved
Hi there, I want to check if a field is number only.. I've tried with the code below..though when i fill in something like '33q' it doesn't display the alert..
what am i doing wrong ?
<html>
<script language="JavaScript" type="text/javascript" defer="defer">
function checkhuis(eleID){
eleObj = document.forms[0].elements[eleID];
regex = /^[0-9]/;
if ( eleObj.value.length !=0 ){
if ( regex.test(eleObj.value) == false) {
alert('please adjust your number');
eleObj.focus();
}
}
}
</script>
<form name="formpje">
Enter a number then click the button:
<input type=text name="input" id="test" size=10 value="" onblur="checkhuis(this.id)">
<br><br>
</form>
</html>
Hi there, I want to check if a field is number only.. I've tried with the code below..though when i fill in something like '33q' it doesn't display the alert..
what am i doing wrong ?
<html>
<script language="JavaScript" type="text/javascript" defer="defer">
function checkhuis(eleID){
eleObj = document.forms[0].elements[eleID];
regex = /^[0-9]/;
if ( eleObj.value.length !=0 ){
if ( regex.test(eleObj.value) == false) {
alert('please adjust your number');
eleObj.focus();
}
}
}
</script>
<form name="formpje">
Enter a number then click the button:
<input type=text name="input" id="test" size=10 value="" onblur="checkhuis(this.id)">
<br><br>
</form>
</html>