Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

vehicle number formik validation

Yup.string()
      .required("Vehicle Number is Required")
      .test(
        "vehicleNumber",
        "First two letters of the vehicle number should be capitalized and followed by a space, then the vehicle number should be in the format of 'AB 1234' or 'AB 1234 CDE'",
        (value) => {
          return /^[A-Z]{2}[ -][0-9]{1,2}(?: [A-Z])?(?: [A-Z]*)? [0-9]{4}$/i.test(
            value
          );
        }
      ),
 
PREVIOUS NEXT
Tagged: #vehicle #number #formik #validation
ADD COMMENT
Topic
Name
2+2 =