JAVASCRIPT Program with output
JAVASCRIPT Program with output
<html>
<head>
<title>Form validation</title>
<script>
function validate() { var name =
document.forms.RegForm.Name.value;
var email =document.forms.RegForm.EMail.value;
var phone =document.forms.RegForm.Mobile.value;
var regEmail=/^\w+([\.-]?\w+)@\w+([\.-]?\w+)(\.\w{2,3})+$/g;
var regName = /\d+$/g;
if (name == "" || regName.test(name)) { window.alert("Please enter your name properly."); name.focus();
return false;
}
if (email == "" || !regEmail.test(email)) { window.alert("Please enter a valid e-mail address."); email.focus();
return false;
}
if (phone == "" || !regPhone.test(phone)) { alert("Please enter valid phone number."); phone.focus();
return false;
}
return true;
}
</script>
</head>
<body>
<h1>REGISTRATION FORM</h1>
<form name="RegForm" onsubmit="return validate()" method="post">
<table>
<tr>
<th>Name: </th>
<td><input type="text" name="Name"></td>
</tr>
<tr>
<th>E-mail Address:</th>
<td> <input type="text" name="EMail"></td>
</tr>
<tr>
<th>Mobile: </th>
<td><input type="text" name="Mobile"></td>
</tr>
<tr>
<td><input type="submit" value="send" name="Submit"onclick="validate()">
<input type="reset" value="Reset" name="Reset"></td>
</tr>
</form>
</body>
</html>
SOP 3 Create JavaScript program For Count no vowels in String.
<html>
<head>
<title>Count no of vowels</title>
</head>
<body>
<script type="text/javascript">
function countVowel(str) {
const count = str.match(/[aeiou]/gi).length;
return count;
}
<html>
<head>
<title>Palindrome Program </title>
</head>
<body>
<script>
function checkPalindrome(string)
{
else
{
alert("It is Palindrome");
}
<html>
<head>
<title>Temp conversion program</title>
</head>
<body>
<script type="text/javascript">
let celsius = prompt("Enter temperature in Celsius: ");
let fahrenheit = (celsius * 9/5) + 32;
alert(`The temperature in Fahrenheit is ${fahrenheit.toFixed(2)}`);
</script>
</body>
</html>