-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlab2b.html
More file actions
42 lines (40 loc) · 1.21 KB
/
lab2b.html
File metadata and controls
42 lines (40 loc) · 1.21 KB
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
<?xml version="1.0" encoding="UTF-80"?>
<!DOCTYPE html PUBLIC"-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<script type="text/JavaScript">
function validateFields(elem1,elem2)
{
var alphaExp=/^[1-4][a-zA-Z][a-zA-Z][0-9][0-9][a-zA-Z][a-zA-Z][0-9][0-9][0-9]$/;
var sem=/^[1-8]$/;
if(!elem1.value.match(alphaExp) && !elem2.value.match(sem))
{
alert("Invalid usn\Invalid sem");
return false;
}
else if(!elem1.value.match(alphaExp) && elem2.value.match(sem))
{
alert("Invalid usn\Valid sem");
return false;
}
else if(elem1.value.match(alphaExp) && !elem2.value.match(sem))
{
alert("Valid sem\Invalid usn");
return false;
}
else
{
alert("Valid usn\Valid sem");
return true;
}
}
</script>
</head>
<body>
<form>
<label>Enter your usn:<input type='text' id='usn'/></label>
<label>Enter your sem:<input type='text' id='sem'/></label>
<input type='submit' onclick="validateFields(document.getElementById('usn'),(document.getElementById('sem'))" value='Submit'/>
</form>
</body>
</html>