2

I'm very new in magento and will appreciate if someone can give me a step-by -step procedure to 2 validations in the customer registration form in Magento 1.9.

  1. The size of telephone number field should be 10 and numeric
  2. Zipcode should not accept alphabets.

3 Answers 3

2

You can simply add validate class for validation in magento 1.

For Phone Number Validation

'validate-phoneStrict'          => 'Please enter a valid phone number. For example (123) 456-7890 or 123-456-7890.'
'validate-phoneLax'             => 'Please enter a valid phone number. For example (123) 456-7890 or 123-456-7890.'
'validate-fax'                  => 'Please enter a valid fax number. For example (123) 456-7890 or 123-456-7890.'

For Zip Code Validation

'validate-zip'                  => 'Please enter a valid zip code. For example 90602 or 90602-1234.'
'validate-zip-international'    => 'Please enter a valid zip code.'
1

Follow this Link:-

http://inchoo.net/magento/out-of-the-box-form-validation-in-magento/

OR

you can use these classes to validate the Telephone number:-

'validate-phoneStrict'          => 'Please enter a valid phone number. For example (123) 456-7890 or 123-456-7890.'
'validate-phoneLax'             => 'Please enter a valid phone number. For example (123) 456-7890 or 123-456-7890.'

EX:- <input class="required validate-phoneStrict" id="field1" name="field1" />

2
  • Can someone please give a step-by-step way to implement this. Please treat me as a beginner. Thanks. Apr 4, 2017 at 6:54
  • Just go to the phtml of the Registration page app/design/frontend/base/default/template/persistent/customer/form/register.phtml find the field to which your field is generated and the above said class Apr 4, 2017 at 11:42
0

You can use the below extension, it automatically adds validation based on the selected country with the country flags and automatically sets the user country by default based on their Geo IP location.

https://marketplace.magento.com/ananta-module-telephonevalidation.html

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.