-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmobileValidation.js
More file actions
52 lines (47 loc) · 1.69 KB
/
mobileValidation.js
File metadata and controls
52 lines (47 loc) · 1.69 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
// function myfun(){
// var a =document.getElementById("mobilenumber").value;
// if (a=="")
// {
// document.getElementById("msg").innerHTML="please fill field";
// return false;
// }
// if(isNaN(a)){
// document.getElementById("msg").innerHTML="only no. are allowed";
// return false;
// }
// if(a.length<10){
// document.getElementById("msg").innerHTML="mobile number must be 10 digit";
// return false;
// }
// if(a.length>10){
// document.getElementById("msg").innerHTML="mobile number must be 10 digit";
// return false;}
// if((a.charAt(0)!=9) && (a.charAt(0)!=8)&& (a.charAt(0)!=7)){
// document.getElementById("msg").innerHTML="no. must start with 9,8,7";
// return false;
// }
// document.innerHTML='valid';
// return true;}
// ................................................................................................
var phoneError= document.getElementById('msg');
function validatePhone() {
var phone = document.getElementById("mobilenumber").value;
if (phone.length == 0) {
phoneError.innerHTML = "phone no. is required";
return false;
}
if (isNaN(phone)) {
phoneError.innerHTML = "only digit";
return false;
}
if ((phone.charAt(0)!=9) && (phone.charAt(0)!=8)&& (phone.charAt(0)!=7)) {
phoneError.innerHTML = "Number must start with 9,8,7";
return false;
}
if (phone.length !== 10) {
phoneError.innerHTML = "phone no.should be 10 digit";
return false;
}
phoneError.innerHTML = '<i class="fa-solid fa-circle-check"></i>';
return true;
}