Hello i got assignment from my university i am not able to make it properly doing some mistakes well got this assignment
i made this
confused i am stuck what to do now.......anyone Help?
In this whole program
if i put BC102034568@vu.edu.pk in user input text field the alert box show me valid email and if put another email like wj@gmail.com, wj@edu.pk, the alert box must show not valid address.
Code:
[B]Make a form in HTML document containing only one field named as Email and one Submit Button. Write your own JavaScript function to validate the email address.
The Validation should be as follows:
It must accept only your VU Student email address i.e; it must not accept any other student’s VU email address.
It must show alert on acceptance or denial of the email address after validation.
The name of the function should contain your student ID like CheckEmail_BC102034568.
If you enter your wrong student email id then it must show alert as well.
It must accept your student ID only at vu.edu.pk, means if you enter BC102034568@hotmail.com then it must not accept it.
There must be unique alerts for each error; like if the length of the student ID is larger or smaller than the original ID then the alert should be according to that.
During each alert, the entered email address must also be shown in the alert box like: “BC102034560000008@vu.edu.pk is not your Valid Email address”[/B]
i made this
Code:
[B]<html>
<head>
<script type="text/javascript">
function CheckMyEmail()
{
var x=document.forms["myForm"]["email"].value;
var value=("BC102034568");
var at=x.indexOf("@");
var dot=x.lastIndexOf("vu.edu.pk");
if (at<1 || dot<at+2 || dot+2>=x.length)
{
alert("This is Not your valid VU e-mail address");
return false;
}
else
{
alert("This is your valid VU e-mail address");
}
}
</script>
</head>
<body>
<form name="myForm" action="example.html" onsubmit="return CheckMyEmail();" method="post">
Email: <input type="text" name="email">
<input type="submit" value="Submit">
</form>
</body>
</html>[/B]
confused i am stuck what to do now.......anyone Help?
In this whole program
if i put BC102034568@vu.edu.pk in user input text field the alert box show me valid email and if put another email like wj@gmail.com, wj@edu.pk, the alert box must show not valid address.
Last edited: