Search the Community
Showing results for tags 'date validation'.
-
Hello, I need the help on the following in order to validate date on my form (validation is onBlur): - validation on form date format: dd-mm-yyyy , when I go to next field, if the date field is empty, it will be filled with today's date, and I write 9-3 and go to next field it will automatically write 9-3-2013 (where is 2013 is the current year), finally, if the date is not valid then user can't go to another field, focus must be go back to date field. Help is much appreciated. Thanks in advance
-
i've a form user can enter any date , but i want to set a date range validation so the user can't add a date not in this range . for example: from 1-12-2012 to 1-1-2013 , so if user enter 2-1-2013 the system shouldn't accept it.. i've tried this javascript code but it doesn't work and doesn't give me any alert message even when date not in range .. can you help me with this ? or suggest other javascript code i can use instead this is part of my form : echo "<th> Date </th> <td> <input type='date' name='v2' value='' ></td>"; and this is the javascript code i've used <script language="javascript"> function validation(form) { var v2 = document.getElementById('v2'); var date = v2.value; if ( (v2 > new date('12/12/2012')) && (v2 < new date('1/1/2013')) ){ // date is in your valid range return true; } else { // date is not in your valid range alert("date is not in valid range") return false; } } </script>