sal007
11-15-2006, 09:06 PM
Hi people,
Just struggling a little with some scripting..
I've got this form with 3 fields(Name, Email, Idea) and i've currently got some javascript validating it, to make sure that each field has text entered within it.
<script language="JavaScript" type="text/javascript" >
function validate_form ( )
{
valid = true;
if ( document.comp.name.value == "" )
{
alert ( "please provide your name!" );
valid = false;
}
else
if ( document.comp.email.value == "" )
{
alert ( "please provide your email address!" );
valid = false;
}
else
if ( document.comp.idea.value == "" )
{
alert ( "please provide an idea for our student accommodation site" );
valid = false;
}
return valid;
}
</script>
I call this in my form, and it works fine..
<form name="comp" action="sendmail.php" method="post" onsubmit="return validate_form ( );" >
However, I wish to add some extra validation to the "email" field. I've seen plenty of email validation scripts around, but i'm not sure how to incorporate it, as it will be two different functions altogether. I guess I sound like a noob, i'm just not very skilled up when it comes to javascript!
Any help appreciated!
Cheers,
Sal
Just struggling a little with some scripting..
I've got this form with 3 fields(Name, Email, Idea) and i've currently got some javascript validating it, to make sure that each field has text entered within it.
<script language="JavaScript" type="text/javascript" >
function validate_form ( )
{
valid = true;
if ( document.comp.name.value == "" )
{
alert ( "please provide your name!" );
valid = false;
}
else
if ( document.comp.email.value == "" )
{
alert ( "please provide your email address!" );
valid = false;
}
else
if ( document.comp.idea.value == "" )
{
alert ( "please provide an idea for our student accommodation site" );
valid = false;
}
return valid;
}
</script>
I call this in my form, and it works fine..
<form name="comp" action="sendmail.php" method="post" onsubmit="return validate_form ( );" >
However, I wish to add some extra validation to the "email" field. I've seen plenty of email validation scripts around, but i'm not sure how to incorporate it, as it will be two different functions altogether. I guess I sound like a noob, i'm just not very skilled up when it comes to javascript!
Any help appreciated!
Cheers,
Sal