Has anyone ever created a VIN Validator? I am trying to create a textbox where the user will enter in a Vehicle Identification Number and then JS/jQuery will validate if its
Here's a client-side solution using Regular Expressions.
$(function() {
$("#vin").on("keyup blur", function() {
if (validateVin($("#vin").val()))
$("#result").html("That's a VIN");
else
$("#result").html("Not a VIN");
}).trigger("blur");
});
function validateVin(vin) {
var re = new RegExp("^[A-HJ-NPR-Z\\d]{8}[\\dX][A-HJ-NPR-Z\\d]{2}\\d{6}$");
return vin.match(re);
}