Hi! cud anyone tell me where im goin wrong….the validation works…the alert message comes up wen the text boxes are empty however wen u click ok on the pop up msg it goes to the next page (form.jsp) but i dont want it to. can anyone spot wot im doin wrong?
<form name=”example” id=”example” action=”form.jsp” method=”post”>
<script type=”text/javascript”>
<!–
function formValidation(){
for(i=1;i<<%=i%>;i+=2){
var thing = document.getElementById(“text”+i);
if(!notEmpty(thing.value)){
return true;
}
}
var form = document.getElementById(“example”);
form.submit();
}
function notEmpty(elem){
var str = elem.length;
if(elem.length == 0){
alert(“You must fill in all fields”);
return false;
} else {
return true;
}
}
//–>
</script>
<input type=” button” name=”submit” value=”submit” onclick=”formValidation(this)” />
</form>