PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
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.
<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>
Yes, you can do this with either PHP os JavaScript, but you should realize that it IS JavaScript. The reference to Front Page (FrontPage_Form1_Validator) is only the name of the function that validates the form. It could be called anything but the person that wrote it gave it a meaningful function name... meaningful to him that is. Does this code work the way you have it written?