-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvalidations.html
More file actions
59 lines (44 loc) · 1.39 KB
/
validations.html
File metadata and controls
59 lines (44 loc) · 1.39 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
<!--Validations =>checking user inputs
=>form Validations/client side Validations/js Validations
reg exp=>
Regular expressions or regex are patterns are used to match
character combinations in strings.
you can create a regex pattern using the `RegExp` constructor or
by using regex literals enclosed in slash
syn:
const refvar= new RedExp(pattern);
const refvar= /pattern/;
refvar.test(data)=>true,false
they are called wild card characters
word => /ram/ ->user name should contain ram like ram or rama or raman
/i =>/ram/i (ignore case)
/g =>/ram/g (global)
/w =>/ram/w (word)
[p1p2p3...] => multiple patterns (or) =>its like [p1 or p2 or p3 ] but we cannot write or
- => range a-f
\d => digits
\s => symbol
* => any no of char
{count} => {10}
{min,max} => {5,10}
(?=.p1)(?=.p2)(?=.p3) => and
syn: /^ $/
-->
<!DOCTYPE html>
<html lang="em">
<head>
<meta charset="UTF-8">
</head>
<body>
<input type="text" id="un">
<button onclick="checkUser()">Check user</button>
<script>
function checkUser()
{
const exp=new RegExp(/siva/i);
//const exp=/shiva/;
alert(exp.test(un.value));
}
</script>
</body>
</html>