javascript - Have to remove submit button to get js to work -
I am trying to validate the login details with an HTML form. The problem is that the submit button does not work with code. So for example if I leave the username and password blank then it will not warn for "invalid user name or password". If I delete the type, "submit" works but the button becomes an input text box with an inclick function which does not look good. I was provided with this code because it is a more secure way of passing more login details than the details I wrote, so I have to confess my ignorance on JS and JSON if I have not provided enough information, but Any guidance will be greatly appreciated How to get a button working with JS It's running on Chrome only Cheers.
HTML code
& lt; Form name = "login" id = "login-form" & gt; Username & lt; Input name = "user name" id = "user name" data-bind = "value: user name" type = "text" value = "" /> Password & lt; Input name = "password" id = "password" data-bind = "value: password" type = "password" value = "" /> & Lt; Input name = "submit" type = "submit" onclick = "myApp.getLogin ()" value = "login" /> & Lt; / Form & gt; /services/login.json?username= "+ myApp.vm.username () +" & amp; Password = "+ myApp.vm.password (); console.log (url); $ .getJSON (url, function) {if (data .response === 'success') {window.location.href =" Profile.jsp ";} and {warnings (" invalid user name or password ");}}); }
Data EG & form; form action = 'formHandler.php' & gt; / Code>. If the verb " attribute is not defined, then it will submit the form to the current URL. You type & lt; input type = '' button '/ & gt; . then and input type =' submit '... From and input type = 'button' is changing. should do the trick :) Then the code will be:
& lt; Form name = "Login" id = "Login-form"> User name Password & lt; Input name = "password" id = "password" data-bind = "value: password" type = "password" value = "" /> & Lt; Input name = "submit" type = "button" onclick = "myApp.getLogin ()" value = "login" /> & Lt; / Form & gt;
Comments
Post a Comment