开发者

How to validate one date from current date in javascript?

In my page one asp.net Textbox to enter the date.

I need to validate the textbox value ( dd-mmm-yyyy format) should be less than or equal to Current Date using Javascript.

validation开发者_Python百科 using javascript when press on enter button.


var myDate1= document.form1.Textbox2.value;

  var date  = myDate1.substring(0,2);
  var month = myDate1.substring(3,5);
  var year  = myDate1.substring(6,10);

  var myDate= new Date(year,month-1,date);

var today = new Date();

if (myDate>today)
  {
  alert("Today is before ");
  }
else
  {
  alert("Today is after ");
  }
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜