Adding a select box to Dreamweavers default verify function

Posted on 2011-10-05
Last Modified: 2012-05-12
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) {; 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

Question by:rivkamak
    LVL 70

    Expert Comment

    by:Jason C. Levine
    Don't use the old Javascript validation behaviors anymore.  Those are only in there for compatibility.  Use Spry Validation instead.

    Author Comment

    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.

    Author Comment

    I'm looking for a pop up box.
    LVL 70

    Accepted Solution

    >> 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.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Course: HTML5 Mobile App Development with PhoneGap

    PhoneGap can help you leverage your already existing HTML5, JavaScript, and CSS skills in order to create and deploy cross-platform mobile apps.This program comprehensively covers HTML5 mobile app development from top to bottom.

    In my daily work (mainly using, I need to write a lot of JavaScript code. One of the most repetitive tasks I do are the jQuery Ajax calls. You know: (CODE) I don't know if for you it's the same, but for me is soooo tedious to write the …
    The task A number given should be formatted for easy reading by separating digits into triads. Format must be made inline via JavaScript, i.e., frameworks / functions are not welcome. So let’s take a number like this “12345678.91¿ and format i…
    The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
    The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

    761 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    15 Experts available now in Live!

    Get 1:1 Help Now