Since, my theme does not handle form validation such as preventing symbols in text fields. I decided to use html5 input validations such as min/max for numbers and pattern for text as simple workaround.

I edited register.phtml template at /persistent/customer/form and added html5 validation attributes to email, telephone, pincode etc.

However, I was unable to find input fields of First Name and Last name. They were being generated probably by this snippet :

echo $this->getLayout()->createBlock('customer/widget_name')->setObject($this->getFormData())->setForceUseCustomerAttributes(true)->toHtml();

How do I add a pattern such as pattern="[a-zA-Z0-9\s]+" to First Name and Last Name input fields

1 Answer 1


On my mobile am writing this one, so please make sure the template path by yourself.

The customer names are generated from the template file


. If you want to change the input elements of name fields, then copy that to your theme


As another approach use the prototype validation class validate-alphanum in your input element to allow only digits and alphabets. Please check the file js/prototype/validation.js for your reference.

Your Answer

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

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