Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Regex pattern or min,max number not working #29

Closed
nikhil4326 opened this issue Sep 15, 2017 · 2 comments
Closed

Regex pattern or min,max number not working #29

nikhil4326 opened this issue Sep 15, 2017 · 2 comments

Comments

@nikhil4326
Copy link

I was trying to add validation for zipcode in textvalidator.
Like Below
<TextValidator
ref='zipCode'
hintText="ex. 00000"
name='zipCode'
onBlur={this.handleBlur}
onChange={this.onChange}
value={this.state.zipCode}
validators={['required','matchRegexp:^\d{5}$']}
errorMessages={[ 'Field is required','Zip Code should have 5 digits']}/>
OR
<TextValidator
ref='zipCode'
hintText="ex. 00000"
name='zipCode'
onBlur={this.handleBlur}
onChange={this.onChange}
value={this.state.zipCode}
validators={['required','minNumber:5', 'maxNumber:5']}
errorMessages={['Field is required','Zip Code should have 5 digits','Zip Code should have 5 digits']}/>

Both the ways are not working. Please help me on this issue

@NewOldMax
Copy link
Owner

Hi

Just use 'matchRegexp:^\\d{5}$', you should escape \
minNumber and maxNumber are validating value, not count of digits

@ujjwal-shrivastava
Copy link

How can we restrict it ....I mean validator is working fine but I want to restrict the numbers to 5 digits only.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants