I have one form for validating a user, now I'm testing and need give 2 clicks for send, I read in many forums but can not find the solution to my problem.
This is the script code:
<script>
$(function () {
$('#enviar').click( function() {
if($('#correo').val().length > 0 && $('#pwd').val().length > 0){
var pwd2 = MD5($('#pwd').val());
var myData = "correo="+$('#correo').val()+"&pwd="+pwd2;
$.ajax({
type: "POST",
url:"http://myurlthatisworkingfine/registro/login",
data: myData,
dataType: 'json', // Notice! JSONP <-- P (lowercase)
success: function(data) {
alert(data.message);
}
},
error:function(){
alert("Error");
}
});
} else {
alert('Por favor, rellena los dos campos');
}
return false;
});
});
</script>
The form:
<form id="check-user" data-ajax="false">
<fieldset>
<div data-role="fieldcontain">
<label> Usuario </label>
<input type="text" id="correo" name="correo">
</div>
<div data-role="fieldcontain">
<label> Contraseña </label>
<input type="password" id="pwd" name="pwd" >
</div>
<input type="submit" data-role="button" value="Acceder" name="enviar" id="enviar">
<a href="pasword.html" data-role="button" data-icon="home" data-theme="a">He olvidado mi contraseña</a>
</fieldset>
</form>
All works very fine the only problem it´s with submit , i need 2 times for send the form finally. How can I fix this?