MCPcopy Create free account
hub / github.com/codemistic/Web-Development / checkInputs

Function checkInputs

js-form-validator/form.js:15–85  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

13
14
15function checkInputs(){
16 const usernameValue = username.value.trim();
17 const emailValue = email.value.trim();
18 const phoneValue = phone.value.trim();
19 const passwordValue = password.value.trim();
20 const password2Value = password2.value.trim();
21
22//username
23 if( usernameValue === ''){
24 setErrorFor(username, 'Username cannot be blank');
25 }
26
27 else if(usernameValue.length<=4){
28 setErrorFor(username, 'Username minimum 5 character ');
29 }
30
31 else {
32 setSuccessFor(username);
33 }
34
35 //email
36
37 if(emailValue === ''){
38 setErrorFor(email, 'Email cannot be blank');
39 }
40 else if (!isEmail(emailValue)) {
41 setErrorFor(email, 'Not a valid email');
42 }
43 else{
44 setSuccessFor(email);
45 }
46
47
48 //phone number
49 if(phoneValue === ''){
50 setErrorFor(phone, 'Phone no. cannot be blank');
51 }
52 else if(phoneValue.length != 10){
53setErrorFor(phone,'Not a valid Phone no ');
54 }
55 else{
56 setSuccessFor(phone);
57 }
58
59 //password
60 if(passwordValue === '') {
61 setErrorFor(password, 'Password cannot be blank');
62 }
63
64 else if(passwordValue.length<=8){
65 setErrorFor(password,'Minimum 8 characters required')
66 }
67 else {
68 setSuccessFor(password);
69 }
70
71 //confirm password
72

Callers 1

form.jsFile · 0.70

Calls 3

setErrorForFunction · 0.85
setSuccessForFunction · 0.85
isEmailFunction · 0.85

Tested by

no test coverage detected