Hi all,
basically the source code which had been causing me problem is below. When i try to call the checkMail() below, the page would not stop to check. For example, if i enter the format of an email address wrongly, javascript would not set the focus back to the email field textbox but just display the alert and post the data to the subsequent php form.
What's happening? Thanks again for any suggestions.
function Form_Validate()
{
//looping thru' name, email, tel fields to determine whether user had input information
for (i=0;i<3;i++)
{
box = document.input_all.elements;
if (!box.value)
{
alert('You haven\'t filled in ' + box.name + '!')
box.focus()
return false
}
if(i == 2)
{
checkMail()
}
}
return true
}
function checkMail()
{
var x = document.input_all.email.value;
var filter = /([a-zA-Z0-9_.-])+@(([a-zA-Z0-9-])+.)+([a-zA-Z0-9])+$/;
if (!filter.test(x))
{
alert('Incorrect email address. Please re-enter')
x.focus()
return false
}
return true
}
cheers!