I want to remove this email validation and user can add mobile number in this field . How to apply this in my custom module..
Please help me...
I want to remove this email validation and user can add mobile number in this field . How to apply this in my custom module..
Please help me...
All validations are defined in
Magento2/lib/web/mage/validation.js
You can see validation-email
"validate-email": [
function (v) {
return $.mage.isEmptyNoTrim(v) || /^([a-z0-9,!\#\$%&'\*\+\/=\?\^_`\{\|\}~-]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z0-9,!\#\$%&'\*\+\/=\?\^_`\{\|\}~-]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*@([a-z0-9-]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z0-9-]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*\.(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]){2,})$/i.test(v);
},
'Please enter a valid email address (Ex: [email protected]).'
],
Override register.phtml to your theme
vendor/magento/module-customer/view/frontend/templates/form/register.phtml
remove 'validate-email':true from data-validate
data-validate="{required:true}"
<input type="email" name="email" autocomplete="email" id="email_address" value="<?php echo $block->escapeHtml($block->getFormData()->getEmail()) ?>" title="<?php /* @escapeNotVerified */ echo __('Email') ?>" class="input-text" data-validate="{required:true}">
Additionally to the above answer you need to change the input type from type="email"
to type="text"
, then it will not be validated anymore as email.