check first two number jquery
// Will work for " 123433 " or "12345634 ", etc.
var value = $(this).val(),
re = /^\s*(\d{4})(\d+)\s*$/, // better to initialize only once somewhere in parent scope
matches = re.exec(value),
expectedCode = 3541,
expectedLength = 13;
if(!!matches) {
var code = matches[1]; // first group is exactly first 4 digits
// in matches[2] you'll find the rest numbers.
if(value.length == expectedLength && code == expectedCode) {
// Change the color...
}
}
Also in JavaScript:
- how to add object to array javascript
- how to run electron and react using concurrently
- chack var exist for skip error on javascript
- javascript regex only letters and spaces
- node check if file exists
- implicit type conversion js
- strapi cloudinary how to use
- oauth2 spring boot react google example
- jQuery add table row
- react axios download zip file
- component unmount useeffect
- jquery get value of td by class
- js check if object is empty
- how to run method in method vue js on load
- push javascript
- node promisify without err
- filereader javascript example
- Material-ui wallet icon
- js save files
- javascript check image src
- 'React' must be in scope when using JSX react/react-in-jsx-scope
- Material-ui add box icon
- json server paging
- go to next route vuejs