Computer Science, asked by math8695, 10 months ago

write a javascript code to enter your name and age . if name id divya and age is 16 then display the statement.

Answers

Answered by swamiayushing1
0
<!DOCTYPE html>
<html>
<head>
<title>Student Information Form</title>
<script type="text/javascript">
function valid()
{
var na = document.getElementById("nm").value;
var ag = document.getElementById("age").value;
var em = document.getElementById("eid").value.indexOf("@");
var mno = document.getElementById("pno").value;
if(na==""||na==null)
{
alert("Enter The Name");
return false;
}
else if(isNaN(ag)||ag<1||ag>100)
{
alert("The age must be a number between 1 and 100");
return false;
}
else if(em==-1)
{
alert("E-mail ID is not valid");
return false;
}
else if(mno==""||mno==null)
{
alert("Enter The Phone No");
return false;
}
else if(isNaN(mno)||mno.length>10||mno.length<10)
{
alert("The mobile no. always has 10 digit numerical value");
return false;
}
else
alert("The Student Information Submitted Successfully");
}
</script>
</head>
<body>
<center><b>
<h3>Student Information Form</h3>
<form action="" onsubmit="return valid()" method="post">
Name: <input type="text" id="nm"><br><br>
Age: <input type="text" id="age"><br><br>
Email id: <input type="text" id="eid"><br><br>
Phone Number: <input type="text" id="pno"><br><br>
<input type="submit" value="Submit">
</form>
</b></center>
</body>
</html>
Similar questions