Posts: 199
Location: High Wycombe, Buckinghamshire, London
|
hello there,
ok, add this script to your head section:
Code:
<script language="JavaScript">
<!--
function validate_form ( )
{
valid = true;
if ( document.form.firstname.value == "" )
{
alert ( "Please fill in the 'Your Name' box." );
valid = false;
}
return valid;
}
//-->
</script>
then this will be how your form looks:
Code:
<form name="form" method="post" action="nextpage" onSubmit="return validate_form ( );">
<h1>Please Enter Your Name</h1>
<p>Your Name: <input type="text" name="firstname"></p>
<p><input type="submit" name="send" value="Send Details"></p>
</form>
Firstly, don't change anything in the initial form tag, but you can chage the method and the action!
When adding more fields, you must add this to the javascript :
Code:
if ( document.form.firstname.value == "" )
{
alert ( "Please fill in the 'Your Name' box." );
valid = false;
}
So, when you add an <input type="text" name="fieldname"> and you want to validate it, you need to add the javascript above. If you want to do more with it, just search on google.
Hope i can help and reply if u need any more help!
Regards,
Sean
__________________
[ Insert witty, yet highly intelligent signature here ]
|