In 1981, Vehicle Identification Numbers (VINs) were standardized using a 17-digit system. Until 1981, manufacturers used VINs that were unique to their own company, and there was no accepted standard for these numbers, so different manufacturers used different formats. http://www.crankshaftcoalition.com/wiki/VIN_decoding
He demanded that all cars sold be equipped with a 17-character VIN, which does not include the letters I (i), O (o) or Q (q) (to avoid confusion with the numbers 1 and 0). http://en.wikipedia.org/wiki/Vehicle_identification_number
So what I'm trying to do is drop and if somewhere from 1980 to 1900 is chosen, VIN will either follow the manufacturers directions or simply not apply at all where the letters I (i), O (o), or Q (q ), and any number of characters / numbers. But then, if RegEx is selected in 1981 and later, and it will be formatted using the expression that I have a valid or invalid VIN.
Connect a valid VIN for testing purposes now. If you delete the last number, it will show "Invalid Vin"
Any suggestions or help would be greatly appreciated!
http://jsfiddle.net/ommLz4th/1/
Regexp
^[A-HJ-NPR-Z\\d]{8}[\\dX][A-HJ-NPR-Z\\d]{2}\\d{6}$
jQuery Vin Validator
$(function() { $("#vin").on("keyup blur", function() { if (validateVin($("#vin").val())) { $("#result").css('color', 'green').html("Valid VIN"); $("#vin").removeClass("not-ok").addClass("ok"); } else { $("#result").css('color', 'red').html("Invalid VIN"); $("#vin").removeClass("ok").addClass("not-ok"); } }); }); 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); }
HTML
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script> <label name="vin">VIN</label> <input type="text" id="vin" value="1FAFP40634F172825" /> <span id="result"></span>
Drop for testing purposes
<select name="vehicleyear" id="vehicleyear"> <option value="">Choose Year</option> <option value="1985">1985</option> <option value="1984">1984</option> <option value="1983">1983</option> <option value="1982">1982</option> <option value="1981">1981</option> <option value="1980">1980</option> <option value="1979">1979</option> <option value="1978">1978</option> <option value="1977">1977</option> <option value="1976">1976</option> <option value="1975">1975</option> <option value="1974">1974</option> </select>
Actual disclosure
<cfparam name="form.vehicleyear" default=""> <cfset VARIABLES.y1=DatePart("yyyy",Now())> <cfset VARIABLES.y2=VARIABLES.y1+2> <cfif Val(form.vehicleyear) LT VARIABLES.y1 or Val(form.vehicleyear) GT VARIABLES.y2> </cfif> <cfoutput> <cfselect name="vehicleyear" id="vehicleyear" required="yes" message="Please select vehicle year."> <option value="" selected="selected">Select Year</option> <cfloop index="i" from="#VARIABLES.y2#" to="1900" step="-1"> <option value="#i#"<cfif form.vehicleyear EQ i> selected</cfif>>#NumberFormat(i,"0000")#</option> </cfloop> </cfselect> </cfoutput>