raynerdurand Posted June 17, 2016 Share Posted June 17, 2016 Hi, I need your help please, I have created a button element in the HTML file, to which assigned the "click" event with a jquery code in a java script file. The problem is that.. when the page is loaded for first time and I open the login form when I press the login button my form close suddenly and it shows "?#" at the end of the URL, I don't know why happens this and I appreciate your help. thanks a lot. Link to comment Share on other sites More sharing options...
Ingolme Posted June 17, 2016 Share Posted June 17, 2016 What do your HTML and Javascript code look like? Link to comment Share on other sites More sharing options...
justsomeguy Posted June 17, 2016 Share Posted June 17, 2016 Are you canceling the default form submit? If not the page will reload when the form submits. Link to comment Share on other sites More sharing options...
raynerdurand Posted June 17, 2016 Author Share Posted June 17, 2016 here I attached a part of the js file and I annexed part of the html file: <form id="formLogin"> <h3 class="h3Form">INGRESE SUS DATOS</h3> <label id="label_correo" class="labelForm">Correo: </label><br> <input id="correo" type="text" title="Ingrese el correo introducido en el proceso de registro" class="inputs"/> <img id="iconCorrectCorreo" class="iconCorrectLog" src="css/img/iconCorrecto.png"> <img id="iconErrorCorreo" class="iconErrorLog" src="css/img/iconError.png"><br> <label id="label_pass" class="labelForm">Password: </label><br> <input id="passLog" type="password" title="Ingrese su contraseña" class="inputs"/> <img id="iconCorrectPassLog" class="iconCorrectLog" src="css/img/iconCorrecto.png"> <img id="iconErrorPassLog" class="iconErrorLog" src="css/img/iconError.png"><br> <label id="label_typeUser" class="labelForm">Tipo de Usuario: </label><br> <select id="typeUser"> <option value="cliente">Cliente</option> <option value="admin">Administrador</option> </select> <img id="iconCorrectTypeUser" class="iconCorrectLog" src="css/img/iconCorrecto.png"> <img id="iconErrorTypeUser" class="iconErrorLog" src="css/img/iconError.png"><br> <button id="buttonLogin" class="botones">LOGIN</button> <a id="recuperaPass" href="#">Recuperar Password</a> <div class="msjFormsLog"><h5 id="msjLogError"></h5></div> </form> jsCode.txt Link to comment Share on other sites More sharing options...
justsomeguy Posted June 17, 2016 Share Posted June 17, 2016 Does the iniciarSesion function cancel the default event action? Link to comment Share on other sites More sharing options...
davej Posted June 18, 2016 Share Posted June 18, 2016 Where is iniciarSesion() in the code and where is id="linkLogin" in the HTML? Link to comment Share on other sites More sharing options...
raynerdurand Posted June 18, 2016 Author Share Posted June 18, 2016 The problem already exist when had assigned the "inicioSesion" Function to the "click" event of the login button, however i attached the full files anyway index.html jsCode.txt Link to comment Share on other sites More sharing options...
Ingolme Posted June 18, 2016 Share Posted June 18, 2016 You have to prevent the form from submitting. Instead of assigning the event to the submit button assign it to the form. Then call preventDefault() on the event object to stop the form from submitting. $('#formLogin').submit(iniciarSesion); function iniciarSesion(e) { "use strict"; e.preventDefault(); // El resto del código sigue a partir de aquí Link to comment Share on other sites More sharing options...
davej Posted June 19, 2016 Share Posted June 19, 2016 Is this page designed to be usable with Javascript disabled? Link to comment Share on other sites More sharing options...
raynerdurand Posted June 20, 2016 Author Share Posted June 20, 2016 Hi.. after of some days and your help I think that I found the problem... this is related with the "mouseup" of the "Click" event.. then I have changed it, to "mousedown" event and solved problem. thanks a lot for your help. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now