日期:2014-05-20  浏览次数:20648 次

JSP页面中如何判断一个text中输入的内容是否是日期型
如题!谢谢!

已有的一段代码,判断是否为空;
 <script language="javascript" type="text/javascript">
  function check(){
  if (shen.name.value ==""){
  alert("公司名称不能为空!");
  return false;
  }
  return true;
  }
</script>

------解决方案--------------------
try
{
var myDay = "2002-11-11";
var invalid = Date.parse(myDay);
return true;
}
catch(e)
{
return false;
}


---------------------
websharp, the simple and the best web technology. http://blog.csdn.net/coolmasoft 

------解决方案--------------------
javascrip :
if (document.Login.t3.value.length==0 || document.Login.t3.value.replace(/\s/g,"")=="" || document.Login.t3.value.match(/^(\d{1,4})(-|\/)(\d{1,2})\2(\d{1,2})$/)==null)
{
alert("请正确填写您的日期(例如:1981-11-12)!");
document.Login.t3.focus();
return (false);
}
------解决方案--------------------
探讨
javascrip :
if (document.Login.t3.value.length==0 || document.Login.t3.value.replace(/\s/g,"")=="" || document.Login.t3.value.match(/^(\d{1,4})(-|\/)(\d{1,2})\2(\d{1,2})$/)==null)
{
alert("请正确填写您的日期(例如:1981-11-12)!");
document.Login.t3.focus();
return (false);
}