Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 3.2.16

Bug #4495 JS Validation on dates is broken
Submitted: 2005-06-01 01:01 UTC
From: danr at sbs dot com dot au Assigned:
Status: Bogus Package: HTML_QuickForm
PHP Version: 5.0.3 OS: N/A
Roadmaps: (Not assigned)    
Subscription  
Comments Add Comment Add patch


Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know! Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem : 27 - 21 = ?

 
 [2005-06-01 01:01 UTC] danr at sbs dot com dot au
Description: ------------ I have an issue getting the validation JS to be triggered when a required date is there, however when i select the empty option, its not triggered, and acts like the date is still selected. This doesnt work on mac or pc Reproduce code: --------------- Here is the js code, and the date menu var date_response_dueElements = '::date_response_due[d]::date_response_due[m]::date_response_due[Y]::'; value = new Array(); var valueIdx = 0; for (var i = 0; i < frm.elements.length; i++) { var _element = frm.elements[i]; if (date_response_dueElements.indexOf('::' + _element.name + '::') >= 0) { switch (_element.type) { case 'checkbox': case 'radio': if (_element.checked) { value[valueIdx++] = _element.value; } break; case 'select': if (-1 != _element.selectedIndex) { value[valueIdx++] = _element.options[_element.selectedIndex].value; } break; default: value[valueIdx++] = _element.value; } } } if (value == '' && !errFlag['date_response_due']) { errFlag['date_response_due'] = true; _qfMsg = _qfMsg + '\n - The field Date Response Due is required.'; } <select name="date_response_due[d]"> <option value="1">01</option> <option value="2" selected="selected">02</option> <option value="3">03</option> <option value="4">04</option> <option value="5">05</option> <option value="6">06</option> <option value="7">07</option> <option value="8">08</option> <option value="9">09</option> <option value="10">10</option> <option value="11">11</option> <option value="12">12</option> <option value="13">13</option> <option value="14">14</option> <option value="15">15</option> <option value="16">16</option> <option value="17">17</option> <option value="18">18</option> <option value="19">19</option> <option value="20">20</option> <option value="21">21</option> <option value="22">22</option> <option value="23">23</option> <option value="24">24</option> <option value="25">25</option> <option value="26">26</option> <option value="27">27</option> <option value="28">28</option> <option value="29">29</option> <option value="30">30</option> <option value="31">31</option> <option value=""></option> </select>-<select name="date_response_due[m]"> <option value="1">01</option> <option value="2">02</option> <option value="3">03</option> <option value="4">04</option> <option value="5">05</option> <option value="6" selected="selected">06</option> <option value="7">07</option> <option value="8">08</option> <option value="9">09</option> <option value="10">10</option> <option value="11">11</option> <option value="12">12</option> <option value=""></option> </select>-<select name="date_response_due[Y]"> <option value="2001">2001</option> <option value="2002">2002</option> <option value="2003">2003</option> <option value="2004">2004</option> <option value="2005" selected="selected">2005</option> <option value="2006">2006</option> <option value="2007">2007</option> <option value="2008">2008</option> <option value="2009">2009</option> <option value="2010">2010</option> <option value=""></option> </select> Expected result: ---------------- Validate the date menu :) Actual result: -------------- Ignores the empty date.

Comments

 [2005-06-08 17:45 UTC] avb
Use addGroupRule() instead of addRule(). And next time post actual code you *write*, not generated code.
 [2005-06-09 00:31 UTC] danr at sbs dot com dot au
Apoligies, this is generated from DB_DataObject_FormBuilder, I will need to play with his code to see if it works. I had also an issue with normal form arrays like fieldname[] checking if its entered or not.