JSFiddle - React, Tailwind, and code Playground

HTML

<body onload="init()">
    
<div id="loginPage" data-role="page">

    <div data-role="header">
        <h1>Auth Demo</h1>
    </div>

    <div data-role="content">    

        <form id="loginForm">
        <div data-role="fieldcontain" class="ui-hide-label">
            <label for="username">Username:</label>
            <input type="text" name="username" id="username" value="" placeholder="Username" />
        </div>

        <div data-role="fieldcontain" class="ui-hide-label">
           <label for="password">Password:</label>
            <input type="password" name="password" id="password" value="" placeholder="Password" />
        </div>

        <input type="submit" value="Login" id="submitButton">
        </form>
        
    </div>

  
</div>

<script>
 $("#loginPage").live("pageinit", function(e) {
        checkPreAuth();
    });
</script>
</body>

JavaScript

function init() {
 document.addEventListener("deviceready", deviceReady, true);
 delete init;
}


function checkPreAuth() {
    var form = $("#loginForm");
    if(window.localStorage["username"] != undefined && window.localStorage["password"] != undefined) {
        $("#username", form).val(window.localStorage["username"]);
        $("#password", form).val(window.localStorage["password"]);
        handleLogin();
    }
}

function handleLogin() {
    var form = $("#loginForm");    
    //disable the button so we can't resubmit while we wait
    $("#submitButton",form).attr("disabled","disabled");
    var u = $("#username", form).val();
    var p = $("#password", form).val();
    console.log("click");
    if(u != '' && p!= '') {
        $.post("http://www.coldfusionjedi.com/demos/2011/nov/10/service.cfc?method=login&returnformat=json", {username:u,password:p}, function(res) {
            if(res == true) {
                //store
                window.localStorage["username"] = u;
                window.localStorage["password"] = p;             
                $.mobile.changePage("some.html");
            } else {
                navigator.notification.alert("Your login failed", function() {});
            }
         $("#submitButton").removeAttr("disabled");
        },"json");
    } else {
       
        navigator.notification.alert("You must enter a username and password", function() {});
        $("#submitButton").removeAttr("disabled");
    }
    return false;
}

function deviceReady() {
    
 $("#loginForm").on("submit",handleLogin);

}