Click here to Skip to main content
15,886,873 members
Please Sign up or sign in to vote.
3.00/5 (1 vote)
See more:
Hi,
I have a form and there is a text box and i want to put validation on that as dd/mm/yyyy and date must start from 2012 like 12/10/2012

please suggest
C#
var chkdate = document.getElementById("date_slot").value
    if(document.getElementById("date_slot").value == "")
    {
        alert("Please enter the Date..!!")
        hh.date_slot.focus();
        return false;
    }
  else if(!chkdate.match(/^(0[1-9]|[12][0-9]|3[01])[\- \/.](?:(0[1-9]|1[012])[\- \/.](19|20)[0-9]{2})$/))
        {
          alert('date format is wrong');
          hh.date_slot.focus();
        return false;
        }




form

XML
<tr>
               <td >Date For Demo :<span class="required" style="color:#64a34f;">*</span> </td>
               <td > <input id="date_slot" name="date" type="text" style="width:150px;"/> (DD/MM/YY)
               </td>
 </tr>



can you please check it and send me the detail code after edit.

Thanks
Posted
Updated 14-Feb-21 4:49am

Hi,
I got it myself.
else if(!chkdate.match(/^(0[1-9]|[12][0-9]|3[01])[\- \/.](?:(0[1-9]|1[012])[\- \/.](201)[2-9]{1})$/))
 
Share this answer
 
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900