multiple type of Validation through javascript -
i want validate text filed , multiple radio button field through javascript.here form code:
<!doctype html> <html> <head> <title>script</title> <script type="text/javascript" src="script.js"></script> </head> <body> <form name="myform"> <table> <tr> <td> <input type="text" name="job_id" placeholder="*booking/job id no : " > </td> <td> <input type="text" name="taxi_id" placeholder="* driver id/taxi id " > </td> </tr> <tr> <td> <input type="text" name="first_name" placeholder="*first name " > </td> <td> <input type="text" name="last_name" placeholder="*last name "> </td> </tr> </table><br> <div class="div1"> <label>1. how long have been using our service?</label><br> <input type="radio" name="fieldset1" value="less month">less month <br> <input type="radio" name="fieldset1" value="more 1 month">more 1 month <br> <input type="radio" name="fieldset1" value="1-7 days">1-7 days <br> <input type="radio" name="fieldset1" value="less month">never used <br> </div><br> <div class="div2"> <label>2. how use our service?</label><br> <input type="radio" name="fieldset2" value="everyday">everyday <br> <input type="radio" name="fieldset2" value="once week">once week <br> <input type="radio" name="fieldset2" value="2 or 3 times week">2 or 3 times week <br> <input type="radio" name="fieldset2" value="once month">once month<br> <input type="radio" name="fieldset2" value="less once month">less once month<br> </div> <div class="div3"> <label>3. how satisfied service?</label><br> <input type="radio" name="fieldset3" value="very satisfied">very satisfied<br> <input type="radio" name="fieldset3" value="satisfied">satisfied <br> <input type="radio" name="fieldset3" value="neutral">neutral<br> <input type="radio" name="fieldset3" value="unsatisfied">unsatisfied<br> <input type="radio" name="fieldset3" value="very unsatisfied">very unsatisfied<br> </div> <div class="div4"> <label>4. impressed service ?</label><br> <input type="radio" name="fieldset4" value="quality">quality<br> <input type="radio" name="fieldset4" value="price">price<br> <input type="radio" name="fieldset4" value="sevice">sevice <br> <input type="radio" name="fieldset4" value="customer service">customer service<br> </div> <div class="div5"> <label>5. disappointed service ?</label><br> <input type="radio" name="fieldset5" value="quality">quality<br> <input type="radio" name="fieldset5" value="price">price<br> <input type="radio" name="fieldset5" value="sevice">sevice <br> <input type="radio" name="fieldset5" value="customer service">customer service<br> </div>
now want validate radio button form in js file.what shortest/best way?
something ?
var method = document.getelementsbyname('fieldset1'); var ischecked_method = false; ( var = 0; < method.length; i++) { if(method[i].checked) { ischecked_method = true; break; } } if(!ischecked_method) { alert("please choose something!"); }
edited :
Comments
Post a Comment