Skip to content

Instantly share code, notes, and snippets.

@maccevedor
Created June 26, 2014 19:55
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 maccevedor/c659be779caceae663a0 to your computer and use it in GitHub Desktop.
Save maccevedor/c659be779caceae663a0 to your computer and use it in GitHub Desktop.
Bloquear con javascript caracteres especiales
//sin permiitr espacios
var r={'special':/[\W]/g}
//con espacios
var s={'special':/[^\w^ñ^(á|é|í|ó|ú)^\s^]/g}
function valid(o,w){
o.value = o.value.replace(r[w],'');
}
function validaremos(o,w){
o.value = o.value.replace(s[w],'');
}
//agregamos al input
onkeyup="validaremos(this,'special')"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment