<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<link rel="stylesheet" href="login.css">
<script src="http://ajax.googleapis.com/ajax/libs/jquery/2.0.0/jquery.min.js"></script>
<script src="jquery.serializeJSON.min.js"></script>
</head>
<body>
<script>
$(document).ready(function(){
$("#submit-button").click(function(e)
{
var username = JSON.serialize($('#username').val().toLowerCase());
console.log($('#username').val());
});
});
</script>
<div class="login-container">
<div class="title">Login Form</div>
<div class="form-fields">
<form name="login-form" id="login-form" method="POST">
<input type="text" name="username" placeholder="Username" required></input>
<input type="password" name="password" placeholder="Password" required></input>
<input type="submit" value="Log in" id="submit-button"></input>
</form>
</div>
I am trying to log the username variable after serializing it but console.log is not printing anything from within the function. What is the best way to debug in this type of situation.
serializeJSONseems suspicious, strings in js don't have method with this nametoLowerCaser()should betoLowerCase(), andserializeJSON()should be used on a DOM element, not on a string.