首页 > 代码库 > javascript prompt示例

javascript prompt示例

<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=http://www.mamicode.com/document.getElementById(‘date‘).value;
if(dateValue=http://www.mamicode.com/=‘‘)
{
alert(‘Please enter a date‘);
return false
}
else
{
while(!checkPattern.test(dateValue)&&dateValue!=null)
{
dateValue=http://www.mamicode.com/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=http://www.mamicode.com/"Check"/>
   <br/>(example 23/01/1933)
   </p>
  </form>
</body>
</html>

javascript prompt示例