Practical 11
Practical 11
Program Code:
Validate Number:
<html lang="en">
<head>
<title>Validation</title>
<script>
var a = /^\(?(\d{3})\)?[-]?(\d{3})[-]?(\d{4})$/;
function tests() {
if (a.test(str))
alert("Valid");
else
alert("Invalid");}
</script>
</head>
<body>
</body>
</html>
Output:
Exercise:
Validate String:
<html lang="en">
<head>
<title>Validation</title>
<script>
var a = /[^abc]/;
function tests() {
if (a.test(str))
alert("Valid input")
else
alert("Invalid input");}
</script>
</head>
<body>
</body>
</html>
Output: