<<BACK    HOME    CNCPT    TTRL    JSsf.net/projects/validateformjs[ u | S | m | ? ]
   rqd dec eml int len mcr bss trm sifAll Concepts
   frm txt pwd txa rdo sl1 chk slmAll Object Types

validate_form.js
Tutorial  [5/8]: VFP-Diagnostics: Multiple forms

[<<  <  >  >>]     view the code

VFP-Diagnostics can be used to diagnose multiple forms on the same page.

The first form

What is your favorite integer between 8 and 20?
[vfpd on]

The other form

To receive our newsletter, give us your email:
[vfpd on]

TOP     The code [5/8]   (try it)     [<<  <  >  >>]

Aside from having multiple forms, each with their own vf-configurations, the only difference in this code is that the names of the forms must be passed into configVF(), configVFPD() and wrtVFPDToolbar().

<HTML><HEAD>
<SCRIPT LANGUAGE="JavaScript1.3" SRC="../../../js_stdc/validate_form.js" TYPE="text/javascript"></SCRIPT>
<SCRIPT LANGUAGE="JavaScript1.3">
//<!---
   loadVF('../../../js_stdc/');
      configVF("CIBC_OFF", -1, "form_fav_int");
      configVFPD("OFF", "CIBC_ON", "ON_LNK",
         "OFF_LNK", "RESET_LNK", "NO_SUCCESS_DDB", "CIBC_SCTN", "CIBC_CRSH_DDB",
         [2, 1], ['RESET1', 'Good1', 'Bad1'], "form_fav_int");

      configVF("CIBC_OFF", -1, "form_e_newsletter");
      configVFPD("OFF", "CIBC_ON", "ON_LNK",
         "OFF_LNK", "RESET_LNK", "NO_SUCCESS_DDB", "CIBC_SCTN", "CIBC_CRSH_DDB",
         [2, 1], ['RESET2', 'Good2', 'Bad2'], "form_e_newsletter");

   function submitGoodValues1(f_orm)  {
      f_orm.fav_int.sMsgRequired = "What's your favorite integer?";
         f_orm.fav_int.sMsgTxtInt = "Your favorite integer must be an *integer* between ~RANGE_MIN~ and ~RANGE_MAX~, inclusive.";
            f_orm.fav_int.iIntMin = 8;
            f_orm.fav_int.iIntMax = 20;
      return doSubmit(f_orm);
   }

      function vfpdtf__RESET1()  {document.form_fav_int.fav_int.value = '';}
      function vfpdtf__Bad1()  {document.form_fav_int.fav_int.value = 'not an integer';}
      function vfpdtf__Good1()  {document.form_fav_int.fav_int.value = 15;}

   function submitGoodValues2(f_orm)  {
      f_orm.email.sMsgRequired = "Hey, you don't have to sign up for our e-newsletter, but if you do, we *really* need your email address.";
      f_orm.email.sMsgTxtEmail = 'That is not a valid email address.  Nice try though.  Nice try though.';
      return doSubmit(f_orm);
   }


      function vfpdtf__RESET2()  {document.form_e_newsletter.email.value = '';}
      function vfpdtf__Bad2()  {document.form_e_newsletter.email.value = 'not an email';}
      function vfpdtf__Good2()  {document.form_e_newsletter.email.value = 'x@x.x';}

   function doSubmit(f_orm)  {
      var sErrors = getFormErrorMsgs(f_orm, '   - ');

      if(sErrors)  {
         alert('OOPS!\n\n' + sErrors);
         return false;

      }  else if(!doSubmitOnSuccess(f_orm))  {
         alert('HOORAY!\n\nForm "submitted" successfully.\n\n(Permanent VF Diagnostics are on, and doSubmitOnSuccess(f_orm) is false.)');
         return false;

      }  else  {
         return true;
      }
   }
//--->
</SCRIPT>
</HEAD><BODY onLoad="completeVFLoad();">


<H3>The first form</H3>
      <FORM NAME="form_fav_int" onSubmit="return submitGoodValues1(this);" METHOD="post">
         What is your favorite integer between 8 and 20?  <INPUT TYPE="text" NAME="fav_int" SIZE="10">
         <BR><INPUT TYPE="submit" VALUE="Here you go">
<SCRIPT LANGUAGE="JavaScript1.3">
//<!---
   document.write('</FORM>');
   wrtVFPDToolbar(undefined, "form_fav_int");
//--->
</SCRIPT>
<HR>
<H3>The other form</H3>
      <FORM NAME="form_e_newsletter" onSubmit="return submitGoodValues2(this);" METHOD="post">
         To receive our newsletter, give us your email:  <INPUT TYPE="text" NAME="email" SIZE="20">
         <BR><INPUT TYPE="submit" VALUE="Send me your e-newsletter">
<SCRIPT LANGUAGE="JavaScript1.3">
//<!---
   document.write('</FORM>');
   wrtVFPDToolbar(undefined, "form_e_newsletter");
//--->
</SCRIPT>


</BODY></HTML>































SourceForge.net Logo

Copyright (C) 2003-2005, Jeff Epstein.   All rights reserved.