I am trying to validate input data while entered the data. Where, I want to validate Input data in digit and Data Format is: 000-000-000. Where, also I have to validate each 000 value range in between (000-255) only.
Like: 000-000-000 to 255-255-255.
onHandleValidation = (event, submitted) =>
{
let fields = this.state.formFields;
let errors = this.state.formErrors;
let field = (event)? event.target.name: "";
let Validate = true;
if (field === 'digit' || submitted) {
if(fields.digit=== ""){
errors["digit"] = "This field is required";
Validate = false;
} else {
if(/^\d{3}-\d{3}-\d{3}$/.test(fields.digit) === false){
errors['digit'] = "digit Format 000-000-0000 Required";
Validate = false;
}
}
}
this.setState({formErrors: errors, formValid: formValid});
return Validate;
}
Validation for Format: 000-000-000 is done. For second Validation, I am trying, but, Not find any solution yet.
For Any Help. Thank You!
