Skip to content

Instantly share code, notes, and snippets.

@carloshs92
Last active August 29, 2015 14:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save carloshs92/007fbb83dc0dd321e0bf to your computer and use it in GitHub Desktop.
Save carloshs92/007fbb83dc0dd321e0bf to your computer and use it in GitHub Desktop.
Custom ParsleyValidator
window.ParsleyValidator.addValidator("document", (value, requirement) ->
tipo = parseInt($(dom.selDocument).val())
switch tipo
#DNI
when 1
error_msg = 'dni'
value.length == 8
#RUC
when 2
error_msg = 'ruc'
value.length == 11
#PASAPORTE
when 3
error_msg = 'pasaporte'
value.length >= 10 and value.length <= 12
else
false
, 32).addMessage "es", "document", "error :V %s"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment