Css 12,13
Css 12,13
<form name="myform">
Name: <input type="text" name="name"><br><br>
Age: <input type="number" name="age"><br><br>
Phone: <input type="number" name="phone"><br><br>
Email: <input type="email" name="email"><br><br>
Gender: <br>
<input type="radio" name="gender" value="Male" checked> Male
<input type="radio" name="gender" value="Female"> Female<br><br>
<input type="button" value="Submit" onclick="validate()">
</form>
<script>
function validate()
{ var namepat = /^[A-z]{2,20}/;
var emailpat = /^\w+@\w+\.\w+/;
var agepat = /^[0-9]{1,3}/;
var phonepat = /^[789][0-9]{9}/;
var name = document.myform.name.value;
var age = document.myform.age.value;
var phone = document.myform.phone.value;
var email = document.myform.email.value;
if(!namepat.test(name))
{ alert("Invalid Name!"); }
else if(!agepat.test(age))
{ alert("Invalid Age!"); }
else if(!phonepat.test(phone))
{ alert("Invalid Phone Number!"); }
else if(!emailpat.test(email))
{ alert("Invalid Email!"); }
else
{
document.myform.submit();
}
}
</script>
</body>
</html>
<html>
<body>
<p id="text" onmouseover="changeText()" onmouseout="resetText()">
Hover over this text to see the magic!
</p>
<script>
function changeText() {
document.getElementById("text").innerText = "You are hovering over me!";
}
function resetText() {
document.getElementById("text").innerText = "Hover over this text to see the
magic!";
}
</script>
</body>
</html>