Skip to content

Instantly share code, notes, and snippets.

@devacto
Created November 13, 2013 05:07
Show Gist options
  • Save devacto/7444032 to your computer and use it in GitHub Desktop.
Save devacto/7444032 to your computer and use it in GitHub Desktop.
Example of using regex with Javascript.
// Validate IMEI numbers.
$('#RequestProofOfPurchaseFloorStockForm').find('.imei').each(function() {
var pattern = /^(?!\b(.)\1+\b)\d{15}$/gi;
if(pattern.test($(this).val()) == false) {
validate = false;
$(this).addClass('err');
$(this).parent().find('label').addClass('err');
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment