View Full Version : Help for Developing Script

05-24-2012, 02:24 PM
In my form there are two text fields so when i navigate from 1st textfield to 2nd textfield a alert box needed to be displayed validating the data in 1st textfield like it should be numbers . The checking should be done strictly before submission of the form and while during navigating.
Thankx in advance

05-24-2012, 05:11 PM

Philip M
05-24-2012, 08:14 PM
<input type == "text" name = "txt1" onblur = "validate(this)">
<input type == "text" name = "txt2" >

<script type = "text/javascript">
function validate(which) {
var val = which.value;
if (/[^0-9]/g.test(val)) {
alert ("This box may contain integer numbers only");
document.forms[0].txt1.value = "";
setTimeout("document.forms[0].txt1.focus()", 25);

Quizmaster: A barrister's wig is traditionally made from the hair of which animal?
Contestant: A goat