heilhead / react-bootstrap-validation

Form validation for react-bootstrap
MIT License
136 stars 50 forks source link

How to validate input with pattern? #3

Closed anilapu closed 9 years ago

anilapu commented 9 years ago

In my form I want to add pattern validation. How can I achieve this? If you make a list of validate attribute options in readme file it will be helpful.

lemonCMS commented 9 years ago

Like so.

validate={(v,obj)=>{
  var re = /(?=.*\d)(?=.*[a-z])(?=.*[A-Z]).{6,}/;
  return !Validator.isNull(v) && re.test(v);;
}}
heilhead commented 9 years ago

Yes, you should use callback function to validate the value as @lemonCMS showed.