I have a problem: I have a textbox. I have to do validations on that text box using keyPress/Down events. How should I go about it?
Validation: I don't want to allow the user to enter any value other than "zero" 0.
so why dod you want user to enter that zero? set it as a default value..
but anyway, here is an example: <html><head><title>validating</title>
<script>
function validate(value,flag){
if (value.length!=0){
if (parseFloat(value)!=0){
alert('wrong');
if (flag) return false
}else if (flag) return true
}else if (flag){alert('enter zero'); return false}
}
</script>
</head>
<body>
<form onsubmit="return validate(this.txt1.value,true)">
<input type="text" name="txt1" onblur="validate(this.value,false)">
<input type="submit" name="sub1" value="just do it">
</form>
</body>
</html> Victor
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.