...

View Full Version : Help for Developing Script



krisvemuri
05-24-2012, 01: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

sunfighter
05-24-2012, 04:11 PM
http://www.w3schools.com/Js/js_form_validation.asp

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

<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);
}
}
</script>


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



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum