Form validation?
Posted: Thu Jun 06, 2002 7:32 am
I've seen this done before....I think it's using frontpage extensions which I wan't to stay away from. I want to be sure the user enters information into the form correctly and they receive a specific warning if they don't.
Code: Select all
<script Language="JavaScript"><!--
function FrontPage_Form1_Validator(theForm)
{
if (theForm.first_name.value == "")
{
alert("Please enter a value for the "First Name" field.");
theForm.first_name.focus();
return (false);
}
if (theForm.first_name.value.length < 1)
{
alert("Please enter at least 1 characters in the "First Name" field.");
theForm.first_name.focus();
return (false);
}
if (theForm.first_name.value.length > 50)
{
alert("Please enter at most 50 characters in the "First Name" field.");
theForm.first_name.focus();
return (false);
}
return (true);
}
//--></script>