Sat, 2011-12-10 06:57
Dear Experts
In following codes alert() does not work, please check what is wrong?
<script language="javascript"> function isNumberKey(evt) { var charCode = (evt.which) ? evt.which : event.keyCode; if (charCode > 31 && (charCode < 48 || charCode > 57)) { return false; } else { return true; alert("Only Numeric") } } </script>
Sat, 2011-12-10 13:49
#1
Homework?
This looks very much like a class assignment. You're supposed to work these problems out for yourself.
However, I'm bored at the moment, so …
You have this,
else { return true; alert("Only Numeric") }
I didn't look at the decision part, so if there's a problem there, :shrug:
cheers,
gary
Sun, 2011-12-11 22:37
#2
Gary you go to top of the
Gary you go to top of the class
Tue, 2012-02-21 08:24
#3
once the value will return by
once the value will return by return true; it will not coming up again. we need to put that alert message before that return statement.
like this:
<script language="javascript"> function isNumberKey(evt) { var charCode = (evt.which) ? evt.which : event.keyCode; if (charCode > 31 && (charCode < 48 || charCode > 57)) { alert("its fine now"); return false; } else { alert("Only Numeric"); return true; } } </script>
Tue, 2012-02-21 10:39
#4