I have been using this simple js function to validate a field in a form is filled in.
<script language="JavaScript">
<!--
function SubmitForm()
{
var form = document.formname
if (form.client_id.value.length == 0)
{
alert('Please make a selection from the list');
form.client_id.focus();
}
else
{
form.submit();
}
}
//-->
</script>
Now I have a page with multiple forms and I would like to use the same script to validate depending on which form is submitted. I thought I should be able to do something like this… but know very little javascript…any suggestions?
<script language="JavaScript">
<!--
function SubmitForm(x)
{
var form = document.x
if (form.client_id.value.length == 0)
{
alert('Please make a selection from the list');
form.client_id.focus();
}
else
{
form.submit();
}
}
//-->
</script>
Here is the code for the form submission link I am using:
<a href=javascript:SubmitForm(formname) target='_self' onFocus='if(this.blur)this.blur()'> select </a>