ainoy31 Posted August 12, 2008 Share Posted August 12, 2008 Hello- I need help with validating my inputs on a form. Is here my submit code. I highlighted the two input names and the submit action. <ul> <li><?=$langContent[$section]['custom_range'];?>: <?=$langContent[$section]['from'];?> <input type="text" class="DW100" id="f_date_c" [b]name="start_date"[/b] readonly="1" / value="" /><img src="/includes/calendar/ico_calendar.gif" align="top" width="30" height="22" id="f_trigger_c" style="cursor: pointer;" title="Date selector" onmouseover="this.style.background='white';" onmouseout="this.style.background=''" /> <?=$langContent[$section]['to'];?> <input type="text" class="DW100" [b]name="end_date"[/b] id="f_date_c2" readonly="1" / value=""><img src="/includes/calendar/ico_calendar.gif" align="top" width="30" height="22" id="f_trigger_c2" style="cursor: pointer;" title="Date selector" onmouseover="this.style.background='white';" onmouseout="this.style.background=''" /> [b]<div class="ButtonContainer Inline"> <a class="Button Small" href="#" id="FormSubmit" onClick="validateDates(this.form);">[/b]<span><?=$langContent[$section]['view'];?></span></a></div><input type="hidden" name="ckey" value="<?=$customerID;?>"><input type="hidden" name="skey" value="<?=$accountID;?>" /></li> </ul> Here is my javascript for validation. <script language="javascript" type="text/javascript"> <!-- function validateDates(form) { ok = false; if(!document.usage.start_date.value.length == '') { ok = true; } if(!document.usage.end_date.value.length == '') { ok = true; } if(ok = true) { document.usage.submit(); } else { alert("The start and the end dates need to be entered."); } } //--> </script> Thanks for the help. Ainoy Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.