Skip to content

Commit 70b1728

Browse files
Create phoneNumberValidation.js
This function validates the phone number entered by the user. If it is not in the correct format (Indian mobile number with optional 0/91 prefix), the form will not be submitted.
1 parent f609e38 commit 70b1728

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
function onSubmit() {
2+
3+
var phone=g_form.getValue('phone_number_field');//09898989
4+
var pregex=/(0|91)?[6-9][0-9]{9}/;
5+
if(!pregex.test(phone)){
6+
alert("Enter correct phone number");
7+
return false;
8+
}

0 commit comments

Comments
 (0)