0% found this document useful (0 votes)
9 views

Practical 11

Uploaded by

Sanskar Rangole
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views

Practical 11

Uploaded by

Sanskar Rangole
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

Practical 11:

Program Code:

Validate Number:

<html lang="en">

<head>

<title>Validation</title>

<script>

var a = /^\(?(\d{3})\)?[-]?(\d{3})[-]?(\d{4})$/;

function tests() {

var str = t1.value;

if (a.test(str))

alert("Valid");

else

alert("Invalid");}

</script>

</head>

<body>

Enter Phone No: <input type="text" id="t1">

<input type="button" value="Submit" onclick="tests()">

</body>

</html>
Output:
Exercise:

Validate String:

<html lang="en">

<head>

<title>Validation</title>

<script>

var a = /[^abc]/;

function tests() {

var str = t1.value;

if (a.test(str))

alert("Valid input")

else

alert("Invalid input");}

</script>

</head>

<body>

Enter a string: <input type="text" id="t1">

<input type="button" value="Submit" onclick="tests()">

</body>

</html>
Output:

You might also like