validation - Validating multiple sections of the page, but only having one submit button -


i writing page has 1 form tag , 1 submit button, has multiple spots input....

<form> ... </table class="t1">   <tr>     <td><input name="name1" /></td>     <td><input name="stdate" /></td>     <td><input name="enddate" /></td>     <td><input name="description1" /></td>   </tr> </table> <table class="t2">   <tr>     <td><input name="name2" /></td>     <td><input name="date2" /></td>     <td><input name="description2" /></td>     <td><input name="email2" /></td>     <td><input name="id2" /></td>   </tr> </table> <table class="t3">   <tr>     <td><input name="name3" /></td>     <td><input name="date3" /></td>     <td><input name="description3" /></td>   </tr> </table> ....   <div align="center" class="submit">     <input class="submit" width="10%" type="submit" name="submit" id="submit" value="submit" />   </div> </form> 

none of these fields required, user can fill out every field or doesn't have fill out of fields. run problem is, if user fills out of fields on table "t1" need require other fields filled out table "t1".....and same table "t2" , "t3". --also, note, input fields unique, bc writing db after submit. help, , please request more info if needed.

you like:

<form ... onsubmit="return validate_form();"> ... </form> <script type="text/javascript">     function validate_form(){         var name_list = document.getelementsbyname('name');         var date_list = document.getelementsbyname('date');         var desc_list = document.getelementsbyname('description');         var is_valid = true;         for( var i=0; i<name_list.length; i++ ){             var n = name_list[i].value.length > 0;             var d = date_list[i].value.length > 0;             var ds = desc_list[i].value.length > 0;             if( !( (n && d && ds) || (!n && !d && !ds) ) ) {                 is_valid = false;             }         }          return is_valid;     } </script> 

something anyway


Comments

Popular posts from this blog

c# - how to write client side events functions for the combobox items -

exception - Python, pyPdf OCR error: pyPdf.utils.PdfReadError: EOF marker not found -