0

I have a sign up model in which i have name field to input name only. That name field i have declare in signup Form model rule as "required". But i want only text input of combination of capital & small letters to be allowed. There should not be any special character & even numbers in the name. What is the rule for that???

rule is:

[['full_name', 'email', 'input_password', 'input_confirm_password'], 'required']

out of this i want to apply the above one for full_name only. How to do that??

lin
  • 17,956
  • 4
  • 59
  • 83
Shaggie
  • 1,799
  • 7
  • 34
  • 63

1 Answers1

1

You can see the full list of available validators here. RegularExpressionValidator is suitable for your purpose.

Add this to your rules:

['full_name', 'match', 'pattern' => '...'],

The pattern depends on language that you are using for names. For english letters it's trivial task and you can just specify the letters.

Otherwise it's more complex. You can check for example this question.

Alternatively you can exclude only most undesirable characters.

Another way it's just leave that on conscience of user and use StringValidator:

['full_name', 'string'],
Community
  • 1
  • 1
arogachev
  • 33,150
  • 7
  • 114
  • 117