Program:
<html>
<head>
<script language="javascript">
function validate()
{
var amt=document.forms[0].elements[2].value;
var card=document.forms[0].elements[3].value;
var amt_re=new RegExp("^[0-9][0-9]+$","g");
var card_re=new RegExp("^[0-9][0-9]+$","g");
if(!amt.match(amt_re))
{
alert("amount should contan only digits");
//document.forms[0].elements[2].select();
}
if(card.length!=16)
{
alert("credit card number must contain 16 digits ");
//document.forms[0].elements[3].select();
}
}
</script>
</head>
<body bgcolor="yellow">
<form name="myform">
<h1 align="center">Payment Page</h1>
<div align="center"><pre>
LOGIN ID <input type="text" name="id"><br>
PASSWORD <input type="password" name="pwd"><br>
AMOUNT <input type="text" name="amount"><br>
CREDITCARDNUMBER<input type="PASSWORD" name="num+"><br></pre><br><br>
</div>
<br><br>
<div align="center">
<input type="submit" value="ok" onClick="validate()">
<input type="reset" value="clear" >
</form>
<body>
</html>
No comments:
Post a Comment