I have a date input
<input type="date" id="a" name="a" required />
Now i want its value to be set by user but it has to be set only after two days of current day, how do i do that using javascript or jquery?
What i already tried is -
<form id="f">
<input type="date" id="d" />
<input type="submit" value="submit" />
</form>
$("#f").submit( function(e){
var date=new Date();
date = date.getDate()+2;
if($("#d").val()<date){
alert("fail");
e.preventDefault();
}else{
alert("Success");
}
} );
You need to create a date object and compare it to another date object set 2 days ahead.
See Fiddle: http://jsfiddle.net/g6aFz/
$("#f").submit( function(e){
var $date = $("#a"),
date = new Date($date.val()),
date2 = new Date()
date2.setDate(date2.getDate() + 2)
if(date < date2){
alert("fail");
e.preventDefault();
}else{
alert("Success");
}
} );
I'm using jQuery validator and jQuery 1.8.3. For some reason my form is submitted twice which causes errors. This is the code: someNameSpace.myValidateFunction = function(){ $('#myForm').validate(...
I'm using jQuery validator and jQuery 1.8.3. For some reason my form is submitted twice which causes errors. This is the code: someNameSpace.myValidateFunction = function(){ $('#myForm').validate(...
Our applications loading process is lengthy, so to provide the user with indication the app is functioning and merely loading, we want to provide a loading/initializing indicator. I tried using WL's ...
Our applications loading process is lengthy, so to provide the user with indication the app is functioning and merely loading, we want to provide a loading/initializing indicator. I tried using WL's ...
I have the following simple example, When the line extends outside the rectangle, I want to clip it. I already have the rectangle used as an outline, what is a simple way to the same rectangle as a ...
I have the following simple example, When the line extends outside the rectangle, I want to clip it. I already have the rectangle used as an outline, what is a simple way to the same rectangle as a ...
I'm trying to learn Knockout and I'm following these two tutorials: Tutorial 1 Better list example But after half a day of trying (and failing), I'm not able to add or remove an item. Here is my ...
I'm trying to learn Knockout and I'm following these two tutorials: Tutorial 1 Better list example But after half a day of trying (and failing), I'm not able to add or remove an item. Here is my ...