Hey Matt,

 

 

This seems to work for me (Firefox)

 

<script language="_javascript_">

 

 function loopval(formname) {

  // set up form variables

  var re = /^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,3}|[0-9]{1,3})(\]?)$/;

  theForm = document.testForm

  looplen = theForm.length;

  var errorInd =0;

  var errorMsg ='The following errors were found\n';

 

   // alert(looplen);

    //loop over length of form

   for(i=0 ; i<looplen ; i++) {

    // alert(i);

            //

    //setup looping vars

    switchObj = theForm[i].getAttribute('Validate');

     formVal = theForm[i].value;

     fieldName = theForm[i].name;

     // NETSCAPE CHECK alert(theForm[i].validate.value);

    //switch statement

    switch(switchObj) {

     case 'txt' : if (!isNaN(formVal)) {

        errorInd=1;

        errorMsg =errorMsg + 'The field '+fieldName+' must contain alphanumerics\n';

 

        };

     break;

     case 'nmb' : if (isNaN(formVal)) {

        errorInd=1;

        errorMsg = errorMsg +'The field '+fieldName+' must contain only numbers\n';

 

        };

     break;

     case 'email' : if(!formVal.match(re)) {

         errorInd=1;

         errorMsg = errorMsg +'The field '+fieldName+' must contain a syntactically valid Email address\n';

         };

        break;

   

    }

   }

   if (errorInd ==1) {

    alert(errorMsg); 

    }

   else {theForm.submit(); }

  }

 

</script>

 

 

<form name="testForm" method="post" action="" >

 

 <input type="text" name="txtbox"  validate="nmb">

 <input type="text" name="txtbox"   validate="nmb">

 <input type="text" name="txtbox"   validate="email">

 <input type="text" name="txtbox"   validate="that">

 <input type="text" name="txtbox"   validate="other">

 <input type="submit" value="submit" value="submit" >

 

</form>

 

 

 

 

 


From: Matt Horn [mailto:[EMAIL PROTECTED]
Sent: 20 July 2004 14:42
To: [EMAIL PROTECTED]
Subject: Re: [ cf-dev ] OT : Custom form attribs + Netscape

 

hmm doesnt seem to work properly

 

in that I dont get the errormsg alert

 but at least it now sees the validate attrib

 

thanks for your help

when I get it going i'll post the code

 

 Matt

 

 

This e-mail is from Reed Exhibitions (Oriel House, 26 The Quadrant, Richmond, Surrey, TW9 1DL, United Kingdom), a division of Reed Business, Registered in England, Number 678540. It contains information which is confidential and may also be privileged. It is for the exclusive use of the intended recipient(s). If you are not the intended recipient(s) please note that any form of distribution, copying or use of this communication or the information in it is strictly prohibited and may be unlawful. If you have received this communication in error please return it to the sender or call our switchboard on +44 (0) 20 89107910. The opinions expressed within this communication are not necessarily those expressed by Reed Exhibitions. Visit our website at http://www.reedexpo.com

Reply via email to