-
Notifications
You must be signed in to change notification settings - Fork 3
/
validation.js
67 lines (63 loc) · 976 Bytes
/
validation.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
function formValidation()
{
var uname = document.registration.username;
var utel = document.registration.telephone;
var uemail = document.registration.email;
if(allLetter(uname))
{
if(alphanumeric(utel))
{
if(ValidateEmail(uemail))
{
}
}
return false;
}
function allLetter(uname)
{
var letters = /^[A-Za-z]+$/;
if(uname.value.match(letters))
{
return true;
}
else
{
alert('Username must have alphabet characters only');
uname.focus();
return false;
}
}
function alphanumeric(utel)
{
var letters = /^[0-9]+$/;
if(utel.value.match(letters))
{
return true;
}
else
{
alert('User telephone must have numeric characters only');
utel.focus();
return false;
}
}
function ValidateEmail(uemail)
{
var mailformat = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/;
if(uemail.value.match(mailformat))
{
return true;
}
else
{
alert("You have entered an invalid email address!");
return false;
}
}
else
{
alert('Form Succesfully Submitted');
window.location.reload()
return true;
}
}