Need javascript code for validating date greater than 2 days from current date

Posted by Parthibansk under JavaScript on 7/2/2013 | Points: 10 | Views : 1756 | Status : [Member] | Replies : 1
i have a date column in booking form..customer should reserve before 2 days in advance...

how to validate...need javascript code..




Responses

Posted by: Jitendrasoft09 on: 7/2/2013 [Member] [MVP] Starter | Points: 25

Up
0
Down
Hi Parthibansk.
you can use regular expression to validate advance two days date with following code or you can use add() method of datetime in your code.

function checkForm(form)

{
// regular expression to match required date format
re = /^(\d{1,2})\/(\d{1,2})\/(\d{4})$/;

if(form.startdate.value != '') {
if(regs = form.startdate.value.match(re)) {
// day value between 1 and 31
if(regs[1] > 2 ) {
alert("Invalid value for day: " + regs[1]);
form.startdate.focus();
return false;
}

Refer below link to get more details
http://www.the-art-of-web.com/javascript/validate-date/#.UdLmq_k3tgg

Jitendra Kumar
If my post helps you, plz mark as an answer.

Parthibansk, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response