-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjava-script-validation.htm
More file actions
87 lines (77 loc) · 2.68 KB
/
java-script-validation.htm
File metadata and controls
87 lines (77 loc) · 2.68 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
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
<html>
<head>
<title>Girfa : Javascript Validation</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script>
var Flag = true;
function Validate() {
Flag = true;
if ($("#txtRoll").val() == "")
AddCss("txtRoll");
if ($("#ddlClass").val() == "")
AddCss("ddlClass");
if ($("#txtMessage").val() == "")
AddCss("txtMessage");
}
function AddCss(id) {
Flag = false;
$("#" + id).css("border", "solid 1px red");
$('#' + id).animate({
'marginLeft': "+=10px", //moves right
}, 100);
$('#' + id).animate({
'marginLeft': "+=-10px", //moves right
}, 100);
$('#' + id).animate({
'marginLeft': "+=10px", //moves right
}, 100);
$('#' + id).animate({
'marginLeft': "+=-10px", //moves right
}, 100);
}
function RemoveCss(id) {
$("#" + id).css("border", '');
}
function BlurRemoveCss(id) {
if ($("#" + id).val() != "") {
RemoveCss(id);
}
}
function SaveData() {
Validate();
if (Flag == true) {
alert("Congratulations Implement your code")
}
}
</script>
</head>
<body>
<form>
<table>
<tr>
<td align="right"> Roll :</td>
<td><input type="text" id="txtRoll" onblur="BlurRemoveCss('txtRoll')" /></td>
</tr>
<tr>
<td align="right"> Class : </td>
<td>
<select id="ddlClass" onblur="BlurRemoveCss('ddlClass')">
<option value="">Select Course</option>
<option value="1">O Level</option>
<option value="2">A Level</option>
<option value="3">B Level</option>
<option value="4">C Level</option>
</select>
</td>
</tr>
<tr>
<td align="right"> Message :</td>
<td><textarea id="txtMessage" onblur="BlurRemoveCss('txtMessage')"></textarea></td>
</tr>
<tr>
<td colspan="2" align="center"><input type="button" value="Save" onclick="SaveData()" /></td>
</tr>
</table>
</form>
</body>
</html>