- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRegular_Expression_Part2.html
More file actions
Latest commit
104 lines (92 loc) · 3.62 KB
/
Copy pathRegular_Expression_Part2.html
File metadata and controls
104 lines (92 loc) · 3.62 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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
<!DOCTYPE html>
<htmllang="en">
<head>
<metacharset="UTF-8" />
<metaname="viewport" content="width=device-width, initial-scale=1.0" />
<title>🏴‍☠️ Complete Javascripts Course</title>
<linkhref="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css" rel="stylesheet"
integrity="sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9MuhOf23Q9Ifjh" crossorigin="anonymous" />
<style>
</style>
</head>
<body>
<br/>
<br/>
<center>
<!-- <input type="text" id="item"> -->
<br/>
<divid="wrapper">📃 🏪 👾</div>
<br/>
<inputtype="button" class="btn btn-outline-danger" onClick="myFun()" value="Validate Email">
<divid="message">Complete JavaScript Course</div>
<divid="output"></div>
<inputtype="text" id="email" value="email@gmail.com">
<inputtype="text" id="num" value="123321">
<inputtype="text" id="cha" value="characters">
<br/><br/>
</center>
<script>
window.onload=build;
varmessage=document.getElementById("message");
varoutput=document.getElementById("output");
// number input only digits
// email input
// text input only char
// all need to have content
varoutput=document.getElementById('output');
varstr=
"abasdn skjkj eqwj k JavaScript adsjkj asllk 123432 43453 321 3 34 javascript 432 432 JavaScript 342 JavaScript4121";
functioncEmail(e){
varp=/([a-zA-Z0-9._-]+@[a-zA-Z0-9._-]+\.[a-zA-Z.]+)/ig;
varr=e.match(p);
returnr==null ? false : true;
}
functioncNum(e){
varp=/\D/;
varr=e.match(p);
returnr==null ? true : false;
}
functioncChar(e){
varp=/[^A-Za-z]/ig;
varr=e.match(p);
returnr==null ? true : false;
}
functionmyFun(){
vari=document.getElementsByTagName('input');
for(varx=0;x<i.length;x++){
//console.log(i[x]);
if(i[x].value==""){
console.log('No Value in '+i[x].id);
}
if(i[x].type=="text"){
if(i[x].id=="email"){
if(cEmail(i[x].value)){
console.log('Email Valid');
}else{
console.log('Bad Email');
}
}
if(i[x].id=="num"){
if(cNum(i[x].value)){
console.log('Num only Valid');
}else{
console.log('Non Number in the string');
}
}
if(i[x].id=="cha"){
if(cChar(i[x].value)){
console.log('Char only Valid');
}else{
console.log('Non Char is in the string');
}
}
}
}
}
</script>
<scriptsrc="https://code.jquery.com/jquery-3.5.0.js"
integrity="sha256-r/AaFHrszJtwpe+tHyNi/XCfMxYpbsRg2Uqn0x3s2zc=" crossorigin="anonymous"></script>
<scriptsrc="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.min.js"></script>
<scriptsrc="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.bundle.min.js"></script>
</body>
</html>