function validar(X){
var ar = ["carlos","quintero","30","telefono"];
var valor = $("input[id="+X+"]").val();
if(valor.length == 0 || valor == null || valor.match(/^\s+$/) ){
$("#validacion_"+X).html("No existe esa información");
$("#validacion_"+X).attr('class','noesta');
}else{
$("#validacion_"+X).html("");
$("#validacion_"+X).removeClass('noesta');
}
}
function submit(){
var form = document.getElementById("formulario");
//variable que almacenara la cantidad de inputs que no cumplen una condicion
var cont = 0;
for (i=0;i<form.elements.length;i++){
var valor = form.elements[i].value;
var atr = $(form.elements[i]).attr('id');
if(valor.length == 0 || valor == null || valor.match(/^\s+$/) ){
$("#validacion_"+atr).html("No existe esa información");
$("#validacion_"+atr).attr('class','noesta');
//sumamos a la variable este item si no cumple una condicion
cont = parseInt(cont)+1;
}
}
//verificamos si hay inputs no validados, si esta en 0 enviamos el email, si no cancelamos hasta que se validen
if(cont >=1){
}else{
alert("El formulario fue enviado");
$("#validacion_"+atr).html("");
$("#validacion_"+atr).removeClass('noesta');
}
}
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Fiddle Pages
Your fiddles accessible under a custom domain and a vanity path - the simplest hosting for your personal project.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Get Fiddle Pages with PRO
Your fiddles accessible under a custom domain and a vanity path - the simplest hosting for your personal project.