For the complete documentation index, see llms.txt. This page is also available as Markdown.
Legacy

Phone number validation

Advanced guide to requiring a country code in a form's phone number field when reCAPTCHA is enabled.

This guide shows how to require a country code in the mobile number field of a form when reCAPTCHA is active.

You add code to the form's HTML and, if needed, adjust the regular expression that validates the string. If you used validation before activating reCAPTCHA, switch to the "submit captcha" version of the code in step 2.


1. Add this snippet at the top of the CSS textbox on the Colors & Fonts -> HTML page


$J = jQuery.noConflict();


submitForm = function(){ var jval = jValidate($('formen'),true); if(!jval){ return false; } var regEx = /^\\+\[1-9\]\[0-9\]{7,14}$/; var val = $J('input\[type=tel\]').val(); if (!val || val.match(regEx)) { const siteKey = window.\_\_RECAPTCHA\_SITE\_KEY\_\_; submitCaptchaOK(siteKey); } else { alert('Enter the mobile number with country code'); $J('input\[type=tel\]').focus(); return false; } }


Last updated

Was this helpful?