Skip to content

Commit 01e7c9f

Browse files
emailPhone.js
1 parent 36fcc83 commit 01e7c9f

File tree

1 file changed

+24
-0
lines changed
  • Client-Side Components/Catalog Client Script/Email & Phone Format

1 file changed

+24
-0
lines changed
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
//onSubmit catalog client script Form restriction
2+
function onSubmit(){
3+
var phone = g_form.getValue('preffered_phone');
4+
var mail = g_form.getValue('email_details');
5+
var phnPattern = /^\d{3}-\d{3}-\d{4}/;
6+
var mailPattern = /^[a-zA-Z0-9._%+1]+@(gmail\.com)$/;
7+
8+
if( phone && !phone.match(phnPattern))
9+
{
10+
11+
alert("Phone number format is not correct");
12+
return false;
13+
}
14+
else if(mail && !mail.match(mailPattern))
15+
{
16+
alert("Email format is not correct");
17+
return false;
18+
}
19+
else
20+
{
21+
return true;
22+
}
23+
24+
}

0 commit comments

Comments
 (0)