diff --git a/Client-Side Components/Catalog Client Script/Email & Phone Format/README.md b/Client-Side Components/Catalog Client Script/Email & Phone Format/README.md new file mode 100644 index 0000000000..9818dd3a7a --- /dev/null +++ b/Client-Side Components/Catalog Client Script/Email & Phone Format/README.md @@ -0,0 +1,4 @@ +# Contribution 3 + +My contribution is checking wheather email id format & mobile number format are correct or not during Catalog item Form Submission. Expected Email id Format - "abc12@gmail.com" & Expected Phone number Format - "123 -567 -6789" +If Format match system will allow to submit the Form or else restrict submission of the form. diff --git a/Client-Side Components/Catalog Client Script/Email & Phone Format/emailPhone.js b/Client-Side Components/Catalog Client Script/Email & Phone Format/emailPhone.js new file mode 100644 index 0000000000..2f96670cf5 --- /dev/null +++ b/Client-Side Components/Catalog Client Script/Email & Phone Format/emailPhone.js @@ -0,0 +1,24 @@ +//onSubmit catalog client script Form restriction +function onSubmit(){ +var phone = g_form.getValue('preffered_phone'); +var mail = g_form.getValue('email_details'); +var phnPattern = /^\d{3}-\d{3}-\d{4}/; +var mailPattern = /^[a-zA-Z0-9._%+1]+@(gmail\.com)$/; + +if( phone && !phone.match(phnPattern)) +{ + +alert("Phone number format is not correct"); +return false; +} +else if(mail && !mail.match(mailPattern)) + { +alert("Email format is not correct"); +return false; + } +else +{ + return true; +} + +}