首页 > 编程语言 > 详细

javascript prompt示例

时间:2014-09-16 18:50:40      阅读:239      评论:0      收藏:0      [点我收藏+]

<html lang="en">
<head>
  <title>Date example</title>
<script type="text/javascript">
function checkDate()
{
if(!document.getElementById||!document.createTextNode){return;}
if(!document.getElementById(‘date‘)){return;}
var checkPattern=new RegExp("\\d{2}/\\d{2}/\\d{4}");
var dateValue=document.getElementById(‘date‘).value;
if(dateValue==‘‘)
{
alert(‘Please enter a date‘);
return false
}
else
{
while(!checkPattern.test(dateValue)&&dateValue!=null)
{
dateValue=prompt(‘Your date was not in the right format.‘
+‘Please enter it as DD/MM/YYYY.‘,dateValue);
}
return dateValue!=null;
}
}
</script>
</head>
<body>
  <h1>Events search</h1>
  <form action="eventssearch.php" method="post" onsubmit="return checkDate();">
   <p>
    <label for="date">Date in the format DD/MM/YYYY:</label><br/>
    <input type="text" id="date" name="date"/>
    <input type="submit" value="Check"/>
   <br/>(example 23/01/1933)
   </p>
  </form>
</body>
</html>

javascript prompt示例

原文:http://www.cnblogs.com/vonk/p/3975412.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!