I'm trying to try a simple login page. I add a few text fields and want to read them using javascript or jquery. The issue I'm having is that I'm getting a null error every time using javascript and a blank using jquery, even if I type text into the field.
html:
<label id='userNameLabel' class='inputLabel' for='userNameInput'>Username</label>
<input id='userNameInput' name='User' class='userInput' type='text' value=''>
<label id='passwordLabel' class='inputLabel' for='passwordInput'>Password</label>
<input id='passwordInput' name='Password' class='userInput' type='text' value=''>
<input id='submitSignIn' class='button' type='submit' value='Log In'>
js:
$(document).ready(function(){
$('#submitSignIn').click(function(){
$userName = $('#userNameInput').text();
$userName = $('#passwordInput').text();
$rememberMe = $('#rememberMe').val();
});
})
-or
$(document).ready(function(){
$('#submitSignIn').click(function(){
$userName = document.getElementById(userNameInput).value;
$userName = document.getElementById(passwordInput).value;
$rememberMe = document.getElementById(rememberMe).value;
});
})
Can anyone tell me why I'm having this issue?
.val(), not.text()#rememberMeis undefined. Check my fiddle for a working example: jsfiddle.net/GuyT/9evt6s6b