Web Technologies

Web Technologies 

Slip8

Q.1) Write a JavaScript program to design student registration form and perform following validation: 

- Check all fields should not contain a null value 
- Check name field contains only alphabets
 - Mobile No. field should be of 10 digits.s 
- Pin code field should be of 06 digits.   [Marks 30] 

Solution

Student.html
<html>
<head>
<script>
function reg()
{
var name=document.getElementById("nm").value;
var pno=document.getElementById("mno").value;
var add=document.getElementById("address").value;
var c=document.getElementById("city").value;
var s=document.getElementById("state").value;
var pin_no=document.getElementById("pin").value;
var a=isNaN(name);
if(name==""||pno==""||add==""||c==""||s==""||pin_no=="")
{
alert("check all fields should not contain a null value");
}
if(pin_no<6||pin_no>6)
{
alert("pin code field should be of 6 digits");
}
if(pno!=10)
{
alert("mobile no. field should be of 10 digits");
}
if(a==false)
{
alert("check name field contains only alphabets");
}
}
</script>
</head>
<body>
<form method="post" name="student">
<h1 align="center">student registration form</h1>
<table border=1 align="center">
<tr>
<td>name of student</td>
<td><input type="text" name="nm" id="nm"></td>
</tr>

<tr>
<td>mobile no.</td>
<td><input type="text" name="mno" id="mno"></td>
</tr>

<tr>
<td>address line</td>
<td><input type="text" name="address" id="address"></td>
</tr>

<tr>
<td>city</td>
<td><input type="text" name="city" id="city"></td>
</tr>

<tr>
<td>state</td>
<td><input type="text" name="state" id="state"></td>
</tr>

<tr>
<td>pincode</td>
<td><input type="text" name="pin" id="pin"></td>
</tr>

<tr>
<td><input type="button" value="submit" onclick=reg()></td>
<td><input type="reset" value="reset"</td>
</tr>

</table>
</form>
</body>
</html>
BCA Pratical Solution

My name is Vivek And I from Mumbai and Complete my Graduation Bca.my Age is 23 Years.

Post a Comment

Previous Post Next Post