Created
November 28, 2016 23:35
-
-
Save aranajhonny/8d655d86dc72caaeb075d35b8663b993 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script type="text/javascript"> | |
window.onload = function () { | |
document.crear_producto.focus(); | |
document.crear_producto.addEventListener('submit', validarFormulario); | |
} | |
function validarFormulario(evObject) { | |
evObject.preventDefault(); | |
var todoCorrecto = true; | |
var formulario = document.crear_producto; | |
for (var i=0; i<formulario.length; i++) { | |
if(formulario[i].type =='text') { | |
if (formulario[i].value == null || formulario[i].value.length == 0 || /^\s*$/.test(formulario[i].value)){ | |
swal ('No puede haber campos vacíos'); | |
todoCorrecto=false; | |
} | |
} | |
} | |
if (todoCorrecto ==true) {formulario.submit();} | |
} | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment