-
Notifications
You must be signed in to change notification settings - Fork 9
/
validate.js
90 lines (80 loc) · 3.28 KB
/
validate.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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
//***********************************************//
//* Online Examination System *//
//* Title: Validation *//
//***********************************************//
function isalphanum(ele)
{
var r=/\W$/i;
if(r.test(ele.value))
{
alert("This Field allows Only Alpha Numeric characters.");
ele.value="";
ele.focus();
}
}
function isalpha(ele)
{
var r=/[^a-zA-Z]+/i;
if(r.test(ele.value))
{
alert("This Field allows Only Alphabets.");
ele.value="";
ele.focus();
}
}
function isnum(ele)
{
var r=/\D$/i;
if(r.test(ele.value))
{
alert("This Field allows Only Numerics.");
ele.value="";
ele.focus();
}
}
function validateform(mmyform)
{
var em=/[a-zA-Z0-9]+@[a-zA-Z0-9]+.[a-zA-Z]+/;
myform=document.forms[mmyform];
if(myform.cname.value=="" || myform.password.value=="" || myform.repass.value=="" || myform.email.value=="" || myform.contactno.value=="" || myform.address.value=="" || myform.city.value=="" || myform.pin.value=="")
{
alert("Some of the fields are Empty.");
return false;
// myform.onsubmit=false;
}
else if(myform.password.value!=myform.repass.value)
{
alert("Passwords Donot Match!");
// myform.onsubmit=false;
return false;
}
else if(!em.test(myform.email.value))
{
alert("Enter the E-mail Correctly!");
// myform.onsubmit=false;
return false;
}
}
function validatesubform(mmyform)
{
myform=document.forms[mmyform];
if(myform.subname.value=="" || myform.subdesc.value=="")
{
alert("Some of the fields are Empty.");
myform.onSubmit=false;
}
}
function validatetestform(mmyform)
{
/* myform=document.forms[mmyform];
if(myform.subname.value=="" || myform.subdesc.value=="")
{
alert("Some of the fields are Empty.");
myform.onSubmit=false;
}
*/
}
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/