• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 305
  • Last Modified:

Adding a select box to Dreamweavers default verify function

Under the tag inspector section in Dreamweaver I set up to verify my form.
It only works with text boxes.
Is there a way to add a select box to the equation?
function MM_validateForm() { //v4.0
  if (document.getElementById){
    var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
    for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=document.getElementById(args[i]);
      if (val) { nm=val.name; if ((val=val.value)!="") {
        if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
          if (p<1 || p==(val.length-1)) errors+='- '+nm+' must contain an e-mail address.\n';
        } else if (test!='R') { num = parseFloat(val);
          if (isNaN(val)) errors+='- '+nm+' must contain a number.\n';
          if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
            min=test.substring(8,p); max=test.substring(p+1);
            if (num<min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
      } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' is required.\n'; }
    } if (errors) alert('The following error(s) occurred:\n'+errors);
    document.MM_returnValue = (errors == '');
} }

<input name="button" type="submit" id="button" style="background-color:#FF0; color:#006" onclick="MM_validateForm('Name','','R','Address','','R','Zip Code','','R','Email','','RisEmail','Electric Company','','R','Electric Account','','R','Gas Company','','R','Gas Account','','R');return document.MM_returnValue" value="Submit"/>

Open in new window

  • 2
  • 2
1 Solution
Jason C. LevineNo oneCommented:
Don't use the old Javascript validation behaviors anymore.  Those are only in there for compatibility.  Use Spry Validation instead.
rivkamakAuthor Commented:
but the problem with spry validation you just see next to input box and when I have a long form, and you hit submit, you don't see the red information on the top box.
rivkamakAuthor Commented:
I'm looking for a pop up box.
Jason C. LevineNo oneCommented:
>> when I have a long form

So use JQuery Form Validation if that's a concern as it will also support selects with the kind of alerting you want.  The larger point (and I would think most of the javascript community agrees) is that the internal DW behavior kind of sucks.  It may have been good back in 2001 or so, but in today's world it's dated, tired, and inflexible.

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now