Jump to content

jannasm1

New Members
  • Posts

    1
  • Joined

  • Last visited

jannasm1's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. 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>
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.