Webskater
12-11-2005, 07:57 AM
After years of writing javascript for intranet apps - I am now having to write a public web site.
A typical bit of form validation used in the onsubmit event of a form ...
onsubmit="return check(this)"
and in the function ...
if (RegisterForm.AgencyName.value == '')
{
RegisterForm.AgencyName.focus();
alert('Please enter the agency name');
return false;
}
Works in IE and Firefox in that it detects that the field is empty and puts the alert up - but in Firefox the focus is not set on the correct field - it puts the focus back on the first field in the form.
How can you get this to work in Firefox?
Any help much appreciated.
A typical bit of form validation used in the onsubmit event of a form ...
onsubmit="return check(this)"
and in the function ...
if (RegisterForm.AgencyName.value == '')
{
RegisterForm.AgencyName.focus();
alert('Please enter the agency name');
return false;
}
Works in IE and Firefox in that it detects that the field is empty and puts the alert up - but in Firefox the focus is not set on the correct field - it puts the focus back on the first field in the form.
How can you get this to work in Firefox?
Any help much appreciated.