hi,
i’m facing some difficulties when using the focus() function and was hoping if u could help. i have created the following form in html and this form’s validation in javascript. the form has more fields but with the one that follows i have the problem
<form name=”order” action=”order.php” method=”post” onsubmit=”return validate_order_form(order);”>
Code:
<input type=”text” maxlength=9 name=”afm”>
<input type=”submit” value=”Order” onSubmit=”return validate_order_form(order);”>
<input type=”reset” value=”Reset” name=”clear”>
</form>
<script language=”javascript”>
<!–
function afm(form){
var myStr= new String(form.afm.value);
if(form.afm.value!=”” && myStr.length!=9){
alert(“Παρακαλείστε να συμπληρώσετε σωστά το ΑΦΜ σας.”);
return false;
}
return true;
}
function validate_order_form(form)
{
var flag;
<!– if afm field is filled then check if it has 9 characters length –>
if(form.afm.value!=””){
flag=afm(form);
form.afm.focus();
return false;
}
return true;
}
//–>
</script>
the probem is that i cannot submit the data to the php file because of the focus(). when i removed the focus() it worked just fine. can u sugget me any way to fix this problem without removing focus?
thnx a lot
yona_t