Hi All,

I need to write a javascript for the form in which there are several fileds,
say i need to validate the second field, if the first field is filled 'yes' from(yes/no) combo box(SELECT), then the second filed should be filled with some value, and then the user should not be allowed to fill other
fields until he fills the second field, as the user tries to bring focus on any other fields he should be prompted with alert message and then the focus should be back to second field.

Now i need to write a javascript for this.
Below is the script i wrote, but the issue is i need to call the CheckFiled() function for all the fields avilable in the form, i tried writing onfocus="CheckFiled()" for all the fields in the form.

My question is how can we generalise this function?
Is there a way say we can attach this as a handler, onfocus="CheckFiled()" inside a seperated javascript file, for all fileds?


function CheckFiled()
{
if(document.Form1.Field1.value == "1")
{
if(document.Form1.Field2.value == "")
{
alert(" Fill Value in ipAddress");
document.Form1.Field2.focus();
}
}
}

regards,
lalawala