-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript2.js
39 lines (34 loc) · 994 Bytes
/
script2.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
function clearerrors(){
errors=document.getElementsByClassName('formerror');
for(let item of errors)
{
item.innerHTML="";
}
}
function seterror(id, error){
element=document.getElementById(id);
element.getElementsByClassName('formerror')[0].innerHTML=error;
}
function validateforma(){
var returnval=true;
clearerrors();
var phone=document.forms['Myform2']["number"].value;
if (phone.length!=10)
{
seterror("contact", " *Enter a valid 10-digit phone number");
returnval=false;
}
var bitsid=document.forms['Myform2']['id'].value;
var regexid=/20\d\d[AB].[A-P][A-S]\d\d\d\dP/;
var idcheck= regexid.test(bitsid);
if (idcheck == false)
{
returnval=false;
seterror("bitsid", " *Enter a valid BITS ID");
}
if (bitsid.length!=13){
returnval=false;
seterror("bitsid"," *Enter a valid BITS ID");
}
return returnval;
}