-valido un formulario, jquery basico
-este en vez de tirar un alert, me muestra un tooltip colorido...
-el tooltip no es mas que un titulo, (tittle) de un input, que su texto sera dinamico,
segun sea, "tu campo esta vacio, no puedes ingresar numero . etc
.........................
CREO EL TITLE CON ATTRIB DE JQUERY
como les dije, tenia un tooltip que sea hacia visible cuando hacia hover sobre un elemento.
lo pude hacer que sea el tooltip de una caja input.
cuando valido, y EL CAMPO ESTA VACIO. indico por jquery que con trigger simule un hover sobre el input asi se muestra.. el mensaje...
asi es como quiero que funcione...
1) el input tiene el title vacio, no tiene especificado el title ,
con jquery lo creo, le coloco en este caso "debes ingresar un nombre " y mando el trigger que simule el hover... (en el caso de que la validacion indique que el input esta vacio)
------------------------------
OTRA OPCION
EL TITLE ESTA CREADO VACIO. SE VE UN PEQUEÑO TOOLTIP. INDICO NUEVO MENSAJE PARA QUE APAREZCA EN EL TITLE, POR JQUERY PERO nooo CAMBIA
--------------------------
esto es html
<form id="formulario" class="formular" method="post" action="http://www.google.com"> <fieldset width="200%"> <legend>Formulario de registro</legend> <label> <span>Usuario : </span> <input type="text" id="nombre" title="Debe ingresar un nombre" > <div id="dnombre" ><div> </label> </fieldset> <input id="enviar" class="submit" type="submit" value="enviar"/><hr/></form>
esto es javascript...
ESTO ES LA VALIDACION......
$(document).ready(function(){
$("#formulario").submit(function () {
if($("#nombre").val().length ==0) {
$("#nombre").attr("title","");
$("#nombre").attr("title","el nombre esta vacio");
$("#nombre").trigger('mouseover');
// $("#nombre").removeAttr("title");
return false;
}
return true;
});
});
-------------------------------------------------
ESTO TAMBIEN ES JAVASCRIPT PERO LLAMANDO A OTRA FUNCION, ASI SOLO FUNCIONA, NO HAY QEU TOCAR MUCHO ACA... SI HAY HOVER , MUESTRA EL TOOLTIP...
$(document).ready(function()
{
$('#formulario input[title]').qtip({
position: {
corner: {
target: 'topRight',
tooltip: 'bottomLeft'
}
},
style: {
backgroundColor:'red',
color:'white',
name: 'dark',
padding: '7px 13px',
width: {
max: 210,
min: 0
},
tip: true
}
});
});

NO ENTIENDO POR QUE POR EJEMPLO. CUANDO PONGO QUE TENGA ASIGNADO UN TITLE EL INPUT,
HAGO HOVER , Y ME MUESTRA EL TOOTIP. CON UN MENSAJE .........
DESPUES CUANDO HAGO LA VALIDACION , EL TOOLTIP POR JQUERY ATRIBB TITLE OTRO VALOR. (SIN RECARGAR LA PAGINA) ME SIGUE MOSTRANDO EL PRIMER MENSAJE...
NO CAMBIA , COMO TIENE QUE SER... SI REFRESCO LA PAGINA , -Y NO PASO EL HOVER SOBRE EL INPUT- VOY A VALIDAR DIRECTAMENTE , SI ME CAMBIA EL MENSAJE..
no se si tengo que usar live, on , bind, para que busque desde cero el DOM, ya que en algunos casos, estoy agregando un atributo , un title , con un valor, y entonces capaz, no lo detecte...