Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Mandatory fields in a form

Status
Not open for further replies.

SJTech

Programmer
Jul 3, 2001
26
GB
I have created a form and now want to set mandatory fields. How can I do this in HTML.

Gary
Cas-Sim Webmaster
 
try something like this:
Code:
...
<SCRIPT LANGUAGE=&quot;JAVASCRIPT&quot;>
function Verify()
{
  if (document.frm_Test.F_Text.value == &quot;&quot;)
  {
    alert(&quot;Please enter some text&quot;);
    document.frm_Test.F_Text.focus();
    return false;
  }
  
  return true;
}
</SCRIPT>
</HEAD>

<BODY>
<FORM ACTION=&quot;somepage&quot; NAME=&quot;frm_Test&quot; METHOD=&quot;POST&quot; onSubmit=&quot;return Verify();&quot;>
<INPUT TYPE=&quot;INPUT&quot; NAME=&quot;F_Text&quot; SIZE=20></INPUT>
<INPUT TYPE=&quot;SUBMIT&quot; VALUE=&quot;Submit&quot;>
</FORM>
...
Tony
reddot.gif WIDTH=500 HEIGHT=2 VSPACE=3

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top