Saturday, February 11, 2012

javascript - validateForm()


validação de formulários - javascript

<HTML>
<HEAD>
<script language="javascript">

    <!--
      function validateForm()
      {
        if (document.entryForm.yourname.value=="")
        {
          alert("You haven't entered your name !");
          return false;
        }

        document.entryForm.submit();
        return true;
      }
  // -->

</script>
</HEAD>
<BODY>

<FORM METHOD=POST ACTION="/servlets/demoServlets.MyNameServlet" NAME="entryForm">
<INPUT TYPE="TEXT" SIZE="30" NAME="yourname">
<INPUT TYPE="BUTTON" VALUE="  Submit  " OnClick="validateForm()">
</FORM>

</BODY>
</HTML>

No comments: