<html>
<head>
<title> </title>
<script type="text/javascript">
function validate() {
var currency = document.getElementById("currency").value;
var pattern = /^\d+(?:\.\d{0,2})$/ ;
if (pattern.test(currency)) {
alert("Currency is in valid format");
return true;
}
alert("Currency is not in valid format!Enter in 00.00 format");
return false;
}
</script>
</head>
<body>
<h2>Validating Currency..</h2>
Enter Currency:<input type="text" name="currency" id="currency" />
<input type="submit" value="Check" onclick="validate();" />
</body>
</html>
<head>
<title> </title>
<script type="text/javascript">
function validate() {
var currency = document.getElementById("currency").value;
var pattern = /^\d+(?:\.\d{0,2})$/ ;
if (pattern.test(currency)) {
alert("Currency is in valid format");
return true;
}
alert("Currency is not in valid format!Enter in 00.00 format");
return false;
}
</script>
</head>
<body>
<h2>Validating Currency..</h2>
Enter Currency:<input type="text" name="currency" id="currency" />
<input type="submit" value="Check" onclick="validate();" />
</body>
</html>
No comments:
Post a Comment