Reputation: 856
Hi,I have simple login form, where fields are validated by javascript. I don't now why the below code is not working.
my html and js code:
<head>
<script type="text/javascript">
function handleLogin() {
var u = $("#username").val();
var p = $("#password").val();
if(u=="a" && p=="a")
{
window.location="/Site/site.html";
}
else
{
alert("Fail");
}
}
</script>
</head>
<li dojoType="dojox.mobile.ListItem">
<input dojoType="dojox.mobile.app.TextBox" placeHolder="username" type="text" id="username" name="username" />
</li>
<li dojoType="dojox.mobile.ListItem">
<input dojoType="dojox.mobile.app.TextBox" placeHolder="password" type="password" id="password" name="password" />
</li>
<li dojoType="dojox.mobile.ListItem">
<input dojoType="dojox.mobile.Button" onclick="handleLogin()" type="button" id="submit" name="submit" value="Login"/>
</li>
When I click on the submit button nothings happening.
Thanks
Upvotes: 2
Views: 1206
Reputation: 173562
You didn't load the jQuery library. But you can do without it:
var u = document.getElementById('username').value,
p = document.getElementById('password').value;
Changing the page is done with location.href
instead of window.location
:
location.href = '/Site/site.html';
Upvotes: 4
Reputation: 40318
try to import
<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
Upvotes: 1