-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathOOPFormValidation.html
More file actions
54 lines (48 loc) · 1.05 KB
/
OOPFormValidation.html
File metadata and controls
54 lines (48 loc) · 1.05 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
<input type="text" id="txt" />
<input type="button" id="btn" value="Press"/>
<br/>
<br/>
<input type="text" id="txt2"/>
<input type="text" id="lname"/>
<input type="text" id="mname"/>
<input type="button" id="btn2" value="Press2"/>
<Script>
function ale(a,b,c){
this.a=a;
this.b=b;
this.c=c;
};
ale.prototype.full=function(){
var lname;
if(this.b!=undefined){
if(this.c!=undefined){
lname=this.c+" "+this.b;
}else{
lname=this.b;
}
}else{
lname="";
};
return "Hellow "+this.a+" "+lname;
};
document.getElementById("btn").onclick=function(){
var txt=document.getElementById("txt").value;
var newx=new ale(txt);
if(txt!=""){
alert(newx.full());
}else{
return false;
}
};
document.getElementById("btn2").onclick=function(){
var txt=document.getElementById("txt2");
var lname=document.getElementById("lname");
var mname=document.getElementById("mname");
var newx=new ale(txt.value,mname.value,lname.value)
if(txt.value!=""&&lname.value!=""){
alert(newx.full())
}else{
alert("Fill All The Fields Properly");
}
}
</script>