B
Betty
I have user profile form that i wish to valadate as the user clicks the
submit button.
I have started to try and validate the first couple of fields to see if
this works but it doesnt?
This is the code that i have in the head section...
<script language="JavaScript">
function validateForm()
{
alertText = 'You must complete the required fields';
returnValue = true;
if (document.MobileProfile.UserName == '')
{
alertText = alertText + ' User Name \n';
returnValue = false;
}
if (document.MobileProfile.Department.value == '')
{
alertText = alertText + ' Department \n';
returnValue = false;
}
if (returnValue == false)
{
alert([alertText]);
}
return returnValue;
}
</script>
This is the code that i have in the Form section...
<form method="POST" action="--WEBBOT-SELF--" name="myForm"
onsubmit="validateForm()">
I have also been advised to remove the onsubmit section in the <form>
and to add the following within the codse for the submit button...
<input type="submit" value="Submit" Name="submit" OnClick="javascript:
validateForm();">
Either way i cant seem to get this to work.
Can anyone help?
Kind Regards
Betty
submit button.
I have started to try and validate the first couple of fields to see if
this works but it doesnt?
This is the code that i have in the head section...
<script language="JavaScript">
function validateForm()
{
alertText = 'You must complete the required fields';
returnValue = true;
if (document.MobileProfile.UserName == '')
{
alertText = alertText + ' User Name \n';
returnValue = false;
}
if (document.MobileProfile.Department.value == '')
{
alertText = alertText + ' Department \n';
returnValue = false;
}
if (returnValue == false)
{
alert([alertText]);
}
return returnValue;
}
</script>
This is the code that i have in the Form section...
<form method="POST" action="--WEBBOT-SELF--" name="myForm"
onsubmit="validateForm()">
I have also been advised to remove the onsubmit section in the <form>
and to add the following within the codse for the submit button...
<input type="submit" value="Submit" Name="submit" OnClick="javascript:
validateForm();">
Either way i cant seem to get this to work.
Can anyone help?
Kind Regards
Betty