Skip to content

Instantly share code, notes, and snippets.

@egermano
Created October 30, 2013 21:28
Show Gist options
  • Save egermano/7240614 to your computer and use it in GitHub Desktop.
Save egermano/7240614 to your computer and use it in GitHub Desktop.
Validação de digitação de campos de texto. Valida apenas letras, números, undescore, ífen, ponto, um arroba seguido e um espaço seguido.
$('#form-email').unbind('keypress.pogMask').bind('keypress.pogMask', function(e){
return !!String.fromCharCode(e.keyCode).match(/^[a-z0-9_@\-\. ]+$/gi);
}).unbind('keyup.pogMask').bind('keyup.pogMask', function(){
$(this).val($(this).val().replace(/@{2,}/g, '@'));
$(this).val($(this).val().replace(/\s{2,}/g, ' '));
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment