Jump to content

Making form fields compulsory


unplugged_web

Recommended Posts

I have a form and the results are being sent to a database, but I wanted to know if it is possible to make one of the fields compulsory so that someone is prompted if to file it in if they don't put anything in? I've noticed that most people aren't adding anything to that field, but want them to.ThanksLucy

Link to comment
Share on other sites

The problem with that is, you have to create a nother page error.php for example to diplay the, sorry you missed another page comment.i like to use javascript to do that, so it would prompt the user.

<??><script language="javascript"   type="text/javascript">function validateForm(register){if(""==document.forms.register.email.value){alert("Please enter your email address.");return false;}repeat for more fields} </script> <form name="register" method="post" action="registration_confirm.php" onSubmit="return validateForm(register);"><input type="text" name="email" size="30" value=""></form>

Link to comment
Share on other sites

But careful, users can always disable JavaScript, thereby submitting their invalid form. For ease-of-use, you can use JS, but always have a server-side fallback.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...