Skip to content

Instantly share code, notes, and snippets.

@zine56
Last active May 24, 2021 18:24
Show Gist options
  • Save zine56/f9b97a60aeb1d7a1be2515ba6f5c7f61 to your computer and use it in GitHub Desktop.
Save zine56/f9b97a60aeb1d7a1be2515ba6f5c7f61 to your computer and use it in GitHub Desktop.
test eqp
<html>
<head>
</head>
<body>
<div>
name
<input type=text id=name name=name onkeyup=check(this)>
</div>
<div>
rut
<input type=text id=rut name=rut onkeyup=check(this)>
</div>
<div>
email
<input type=text id=email name=email onkeyup=check(this)>
</div>
</body>
<script>
function check(element){
var value = element.value.trim()
var isRut = new RegExp('^\\d{1,3}(?:\\.\\d{1,3}){2}-[\\dkK]$')
var isEmail = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
var isName = /^[\u00F1A-Za-z _]*[\u00F1A-Za-z][\u00F1A-Za-z _]*$/;
element.value = "";
if(isRut.test(value)){
document.getElementById("rut").value = value;
} else if (isEmail.test(value)) {
document.getElementById("email").value = value;
} else if (isName.test(value)){
document.getElementById("name").value = value;
}
}
</script>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment