Skip to content

Instantly share code, notes, and snippets.

@todd
Created February 17, 2013 08:18
Show Gist options
  • Save todd/4970643 to your computer and use it in GitHub Desktop.
Save todd/4970643 to your computer and use it in GitHub Desktop.
State abbreviation validator for Parsley.js in CoffeeScript.
$("#multipage").parsley
validators:
state: (val)->
val.toUpperCase() in [
'AK','AL','AR','AS','AZ','CA','CO','CT','DC','DE','FL','GA','GU','HI',
'IA','ID','IL','IN','KS','KY','LA','MA','MD','ME','MH','MI','MN','MO',
'MS','MT','NC','ND','NE','NH','NJ','NM','NV','NY','OH','OK','OR','PA',
'PR','PW','RI','SC','SD','TN','TX','UT','VA','VI','VT','WA','WI','WV',
'WY'
]
messages:
state: 'This field is not a valid state abbreviation.'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment