Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6618563
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T20:51:02+00:00 2026-05-25T20:51:02+00:00

I am working on modal login/registration forms. I’m not good with Javascript, but have

  • 0

I am working on modal login/registration forms. I’m not good with Javascript, but have hacked my way to some working Jquery for my Ajax call, and all is working nicely in Chrome 14.0.835.159 beta-m and in Firefox 5 and 6.0.2 and Opera 11.51. I used Firebug to see the JSON returning correctly and updating the error messages.

In FF/Opera/Chrome if I leave the username and login blank and I click the login button on the modal window, the returns count up the failed logins and display the return.I used firebuggerhttp://www.firebugger.com/ to look at what was going on in On IE 7 and 8.

If you leave the form fields blank, it seems the form is somehow “cached” and the call doesnt go through. None of the returns act on my login javascript to update the loginMsg div. If you change the input each time, “a”, “as”, “asd”, the return counts up the failed logins as intended but still no update on my div

Very odd 🙁

The test page is at camarillon.com/testpage.cfm

<!DOCType html>

<html>
<head>
    <title>testpage - test ajax login</title>
    <!-- include the Tools --> 
<script src="http://cdn.jquerytools.org/1.2.5/full/jquery.tools.min.js"></script> 

<!--- add styles --->
<link rel="stylesheet" type="text/css" href="css/loginbox.css" /> 
<!--- <noscript>This is what you see without javascript</noscript> --->

    <CFSET structDelete(session, 'form')>
    <cfset session.form.validate_require="username|'Username' is required.;password|'Password' is required.;confirmpassword|'Confirm password' is a required field.;">
    <cfset session.form.validate_minlength="username|'Username' must be at least 3 characters long.;password|'Password' must be at least 7 characters long.">
    <cfset session.form.validate_maxlength="username|'Username' must be less than 6 characters long.">
    <cfset session.form.validate_alphanumeric="username|'Username' must be alphanumeric.">
    <cfset session.form.validate_password="confirmpassword|password|'Password' and 'Confirm Password' must both match.">

</head>

<body>

<cfparam name="session.auth.loggedIn" default="false">

    <div id="loginMenu">
    <cfif session.auth.loggedIn>
        <a href="logout.cfm">Log out</a>
    <cfelse>
        <button class="modalInput" rel="#login">Login</button>
        <button class="modalInput" rel="#register">Register</button>
    </cfif>
    </div> 


<!-- user input dialog -->
<cfif isDefined("session.auth.failedLogins")>
    <cfset loginMsg=#session.auth.failedLogins# & " failed logins">
<cfelse>
    <cfset loginMsg="Please log in">
</cfif>

<script> 
$(document).ready(function() {
    var triggers = $(".modalInput").overlay({
    // some mask tweaks suitable for modal dialogs
    mask: {
        color: '#ccc',
        loadSpeed: 200,
        opacity: 0.5
    },
    closeOnClick: false,
    onClose: function () {
        $('.error').hide();
    }
});

$("#toomanylogins").overlay({
mask: {
        color: '#ccc', 
        loadSpeed: 200,
        opacity: 0.9
    },
    closeOnClick: false,
    load: false
});

$("#loginForm").submit(function(e) {
    var form = $(this);
    // submit with AJAX
    $.getJSON("cfcs/security.cfc?method=processLogin&ajax=1&returnformat=JSON&queryformat=column&" + form.serialize(), function(json) {
        // everything is ok. (server returned true)
        if (json === true)  {
            // close the overlay
            triggers.eq(0).overlay().close();
            $("#loginMenu").html("<a href='logout.cfm'>Log out</a>");
            // server-side validation failed. use invalidate() to show errors
        } else if (json === "More than five") {
            var tempString
            tempString = "<h2>Too many failed logins </h2>"
            $("#loginMsg").html(tempString);
            triggers.eq(0).overlay().close();
            $("#toomanylogins").overlay().load();
        } else {
            var tempString
            tempString = "<h2>" + json + " failed logins</h2>"
            $("#loginMsg").html(tempString);
        }
    });
    // prevent default form submission logic
    e.preventDefault();
}); 


// initialize validator and add a custom form submission logic
$("#signupForm").validator().submit(function(e) {
    var form = $(this);
    // client-side validation OK.
    if (!e.isDefaultPrevented()) {
        // submit with AJAX
        $.getJSON("cfcs/security.cfc?method=processSignup&returnformat=JSON&queryformat=column&" + form.serialize(), function(json) {
            // everything is ok. (server returned true)
            if (json === true)  {
                // close the overlay
                triggers.eq(1).overlay().close();
                $("#loginMenu").html("<a href='logout.cfm'>Log out</a>");
            // server-side validation failed. use invalidate() to show errors
            } else {
                form.data("validator").invalidate(json);
            }
        });
        // prevent default form submission logic
        e.preventDefault();
    }
});

$.tools.validator.fn("[minlength]", function(input, value) {
    var min = input.attr("minlength");
    return value.length >= min ? true : {     
        en: "Please provide at least " +min+ " character" + (min > 1 ? "s" : ""),
    };
});

$.tools.validator.fn("[data-equals]", "Value not equal with the $1 field", function(input) {
    var name = input.attr("data-equals"),
         field = this.getInputs().filter("[name=" + name + "]"); 
    return input.val() == field.val() ? true : [name]; 
});

});
</script> 

<!-- yes/no dialog -->
<div class="modal" id="toomanylogins">
    <h2>Having problems logging in?</h2>
    <p>
    If you have forgotten your password you can request a reset.
    </p>

    <!-- yes/no buttons -->
    <p>
        <button class="close"> Cancel </button>
    </p>
</div>

<div class="modal" id="login"> 
    <!-- login form --> 
    <form name="loginForm" id="loginForm" autocomplete="off"  method="get" action="">
    <div id="loginMsg"><h2><cfoutput>#loginMsg#</cfoutput></h2></div>
    <p><input type="text" name="username" placeholder="username..." title="Must be at least 8 characters." <!--- required="required"  --->></p>
    <p><input type="password" name="password" placeholder="password..." title="Try to make it hard to guess" <!--- required="required" --->></p>
    <p>
    <button type="submit"> Login </button> 
    <button type="button" class="close"> Cancel </button>
    </p>
    </form>
</div> 

<div  class="modal" id="register">
<!-- signup form-->
    <form id="signupForm"  autocomplete="off" method="get" action=""  novalidate="novalidate">





    <fieldset>
<p>
    <label>firstname *</label>
    <input id="firstname" type="text" name="firstname" placeholder="firstname..." required="required"/></p>
    <p>
    <label>lastname *</label>
    <input type="text" name="lastname" placeholder="lastname..." required="required"/></p>
    <p>
    <label>email *</label>
    <input  type="email" name="email" placeholder="email..." required="required"/></p>
    <p>
    <label>username *</label>
    <input type="text" name="username" placeholder="username..."  required="required"/>     
    </p>
    <p>
    <label>password *<br>
    <input type="password" name="password" required="required" placeholder="password..." /></label>     
    </p>
    <p>
    <label>confirm password *<br>
    <input type="password" name="confirmpassword" data-equals="password"  placeholder="password..."  required="required"/></label>
    </p>
    <p>
        <button type="submit">Sign Up</button>
        <button type="button" class="close"> Cancel </button>
    </p>
       </fieldset>
    </form>
</div>




</body>
</html>

Back end is in Coldfusion, but I don’t think thats relevant, the JSON returns work just fine in FF etc

Any pointers about what I presume is some bug in my Javascript appreciated, my JQuery kung foo is not strong 🙁

Logans solution below is correct … I also had a trailing comma in here which was wrong only bugging out in IE 5-7

$.tools.validator.fn("[minlength]", function(input, value) {
    var min = input.attr("minlength");
    return value.length >= min ? true : {     
        en: "Please provide at least " +min+ " character" + (min > 1 ? "s" : ""),
    };
});

should have been

$.tools.validator.fn("[minlength]", function(input, value) {
    var min = input.attr("minlength");
    return value.length >= min ? true : {     
        en: "Please provide at least " +min+ " character" + (min > 1 ? "s" : "")
    };
});
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T20:51:03+00:00Added an answer on May 25, 2026 at 8:51 pm

    Instead of using $.getJSON, you can use $.ajax and set the cache option to false. I think that sound fix the issue.

    $("#loginForm").submit(function(e) {
        var form = $(this);
    
    
        $.ajax({
            type: 'GET',
            url: "cfcs/security.cfc?method=processLogin&ajax=1&returnformat=JSON&queryformat=column&" + form.serialize(),
            dataType: "json",
            cache: false,
            success: function(json) {
                // everything is ok. (server returned true)
                if (json === true)  {
                    // close the overlay
                    triggers.eq(0).overlay().close();
                    $("#loginMenu").html("<a href='logout.cfm'>Log out</a>");
                    // server-side validation failed. use invalidate() to show errors
                } else if (json === "More than five") {
                    var tempString
                    tempString = "<h2>Too many failed logins </h2>"
                    $("#loginMsg").html(tempString);
                    triggers.eq(0).overlay().close();
                    $("#toomanylogins").overlay().load();
                } else {
                    var tempString
                    tempString = "<h2>" + json + " failed logins</h2>"
                    $("#loginMsg").html(tempString);
                }
            }
        });
    
        // prevent default form submission logic
        e.preventDefault();
    }); 
    
    
    // initialize validator and add a custom form submission logic
    $("#signupForm").validator().submit(function(e) {
        var form = $(this);
        // client-side validation OK.
        if (!e.isDefaultPrevented()) {
            // submit with AJAX
            $.ajax({
                type: 'GET',
                url: "cfcs/security.cfc?method=processSignup&returnformat=JSON&queryformat=column&" + form.serialize(),
                dataType: "json",
                cache: false,
                success: function(json) {
                    // everything is ok. (server returned true)
                    if (json === true)  {
                        // close the overlay
                        triggers.eq(1).overlay().close();
                        $("#loginMenu").html("<a href='logout.cfm'>Log out</a>");
                    // server-side validation failed. use invalidate() to show errors
                    } else {
                        form.data("validator").invalidate(json);
                    }
                }
            });
            // prevent default form submission logic
            e.preventDefault();
        }
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have already working modal login dialog. The problem is that if the origin
I'm using django-registration for registration and login purpose. My Models and Forms.py are working
I ask for some help/advise. I have a jquery form dialog to collect usr/pwd
I'm working on my first user login in Zend, but I'm a little confused
I am working on a site that makes use of jquery modal dialogs to
I have an existing site that is working well with Authlogic login. I'm trying
I'm having difficulty figuring out why user password hashing is not working. The way
I'm working on a flask app that needs authentication. I've hooked up flask-login but
Hello I have been recently working on Django search forms recently and have tired
I've got a modal popup (using ModalPopupExtender) working in a kind of master/detail view

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.