Validation in drop downs on submit button click using javascript -


i have 3 drop-down fields. want validate them using javascript when submit button clicked see if of values in 3 drop-down fields not selected.

on click of submit button should display warning message indicating 1 of 3 drop-downs have not been filled.

based on information in comments previous answer, should work you. have tested can refine javascript if statement test each individually , report different message each long you return false; make sure submission gets halted

function validateform() {    if (document.getelementbyid("ddone").value == "" || document.getelementbyid("ddtwo").value == "" || document.getelementbyid("ddthree").value == "") {      alert("you need fill in 3 dropboxes , not some");      return false;    }  }
<!doctype html>  <html>    <head>  </head>    <body>      <form name="myform" onsubmit="return validateform()" method="post">      <label>dropdown 1</label>      <select id="ddone">        <option value="">none</option>        <option value="opt1">option 1</option>        <option value="opt2">option 2</option>        <option value="opt3">option 3</option>        <option value="opt4">option 4</option>      </select>      <br />      <label>dropdown 2</label>      <select id="ddtwo">        <option value="">none</option>        <option value="opt1">option 1</option>        <option value="opt2">option 2</option>        <option value="opt3">option 3</option>        <option value="opt4">option 4</option>      </select>      <br />      <label>dropdown 3</label>      <select id="ddthree">        <option value="">none</option>        <option value="opt1">option 1</option>        <option value="opt2">option 2</option>        <option value="opt3">option 3</option>        <option value="opt4">option 4</option>      </select>      <br />      <input type="submit" value="submit">    </form>    </body>    </html>


Comments

Popular posts from this blog

Fail to load namespace Spring Security http://www.springframework.org/security/tags -

sql - MySQL query optimization using coalesce -

unity3d - Unity local avoidance in user created world -