Click here to Skip to main content
15,897,891 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Dear,

How to put the validation expression on time.

I have to column Start & End both are datetime.

In time is 24hr format.

What i want, i want to allow user only enter 15 min difference

Example data look like this

Start End
0:00 0:15 ----------> here cannot enter 0:16 or 0:17 or 0:18 so on
0:15 0:30
0:30 0:45

How to do the validation on client side

Thanks
Basit.
Posted
Comments
Suvendu Shekhar Giri 24-Nov-15 0:11am    
Anything you have tried?
basitsar 24-Nov-15 0:34am    
no till now not tried any thing
Inside validation method, just check the difference of both column values by just converting the values to minutes.

1 solution

var starttime ="0:00"
var endtime ="0:15";
var resttime = starttime .replace(starttime , ":");
var resendtime = endtime .replace(endtime , ":");

if((resttime-resendtime) >0:15)
{
alert(" start time and end time have more than 15 sec differences ");
return false;
}
else

{
return true;
}
 
Share this answer
 
v2

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