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

  • SEARCH
  • Home
  • 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 6205741
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T05:19:38+00:00 2026-05-24T05:19:38+00:00

I have a problem in creating an AJAX-based form submission which if its response

  • 0

I have a problem in creating an AJAX-based form submission which if its response is success, it shows a confirmation string at the top of the form, then resets all of the text input, then shows a confirmation dialog box (which has 2 choices: register another username or go to login page), and finally the two choices mentioned redirect the user to the respective page(s).

var $j = jQuery.noConflict();
$j(document).ready(function(){
    var disabled = $j("#submitRegister").button("option","disabled");
    $j("#submitRegister").button();
    function ajax_user_registration(){
       var re9me = $j("#mode_exec").val();
       var re9sh = $j("#securexhash").val();
       var re9xb = $j("#zblank").val();
       var re9un = $j("#requsername").val();
       var re9pw = $j("#reqpassword").val();
       var re9cp = $j("#reqconfpasswd").val();
       var re9ab = $j("#agreebox").val();
       if((re9xb == "") && (re9ab != "")){
            $j.ajax({
            type: "POST",
            url: "registration.php",
            data: 'username='+ re9un +'&password='+ re9pw +'&securehash='+ re9sh +'&agreeconfirm='+ re9ab,
            cache: false,
            success: function(response){
                if(response == 1){
                    $j("#regboxnotice").removeClass().addClass('message-notice').text('Registration: SUCCESSFUL.').fadeIn(1000);
                    $j("#regAccount")[0].reset();
                }else if(response == 0){
                    $j("#regboxnotice").removeClass().addClass('message-negative').text('Registration: FAILED.').fadeIn(1000);
                }else{
                    $j("#regboxnotice").removeClass().addClass('message-negative').text('Registration: FAILED.').fadeIn(1000);
                }
            }
        });
       }
    }
    /* model function for checking username */
function ajax_check_username(){
    var username = $j('#requsername').val();
    if(username == ""){
        $j('#requsername').css('border', '3px #FFD400 solid');
        $j("#regboxnotice").removeClass().addClass('message-notice').text('Username: MIN. 6 CHARS.').fadeIn(1000);
    }else{
        $j.ajax({
            type: "POST",
            url: "validation.php",
            data: 'username='+ username,
            cache: false,
            success: function(response){
                if(response == 1){
                    $j('#requsername').css({'border': '3px #FF0000 solid'});
                    $j("#regboxnotice").removeClass().addClass('message-negative').text('Username: UNAVAILABLE.').fadeIn(1000);
                }else{
                    $j('#requsername').css('border', '3px #009900 solid');
                    $j("#regboxnotice").removeClass().addClass('message-positive').text('Username: AVAILABLE.').fadeIn(1000);
                }
            }
        });
    }
}
    /* model function for checking password */
function ajax_check_password(){
    var password = $j('#reqpassword').val();
    if(password == ""){
        $j('#reqpassword').css('border', '3px #FFD400 solid');
        $j("#regboxnotice").removeClass().addClass('message-notice').text('Password: MIN. 6 CHARS.').fadeIn(1000);
    }else{
        $j('#reqpassword').css('border', '3px #009900 solid');
        $j("#regboxnotice").removeClass().addClass('message-positive').text('Password: OK.').fadeIn(1000);
    }
}
/* model function for checking password-confirmation */
function ajax_check_confpasswd(){
    var password = $j('#reqpassword').val();
    var confpasswd = $j('#reqconfpasswd').val();
    if(confpasswd != password){
        $j('#reqconfpasswd').css('border', '3px #FFD400 solid');
        $j("#regboxnotice").removeClass().addClass('message-negative').text('Conf. Password: RE-TYPE YOUR PASSWORD.').fadeIn(1000);
    }else{
        $j('#reqconfpasswd').css('border', '3px #009900 solid');
        $j("#regboxnotice").removeClass().addClass('message-positive').text('Conf. Password: OK.').fadeIn(1000);
    }
}
    /* AJAX username checking on-the-fly */
    $j('#userzname').keyup(ajax_check_logincomp);
    $j('#requsername').keyup(ajax_check_username);
    $j('#reqpassword').keyup(ajax_check_password);
    $j('#reqconfpasswd').keyup(ajax_check_confpasswd);
    /* AJAX form submission */
    $j('#submitRegister').bind('click', function(event) {
        ajax_user_registration();
        event.preventDefault();
    });
});

Anyway, thank you for your attention.

  • 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-24T05:19:39+00:00Added an answer on May 24, 2026 at 5:19 am

    I created this before you post your code. Simple form with login and password.

    XHTML:

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr" lang="fr">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
        <title>AJAX Form Submission</title>
        <link rel="stylesheet" href="css/jquery-ui.css" type="text/css" media="screen"/>
        <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script>
        <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.14/jquery-ui.min.js"></script>
        <script type="text/javascript" src="my_script.js"></script>
    </head>
    <body>
        <div id="dialog-confirm" title="Registration success">
            <p><span class="ui-icon ui-icon-circle-check" style="float:left; margin:0 7px 20px 0;"></span>Your account have been created successfully.</p>
        </div>
    
        <form method="post" action="#" id="reg_form">
            <p><label for="reg_login">Login</label></p>
            <p><input id="reg_login" type="text"/></p>
    
            <p><label for="reg_password">Password</label></p>
            <p><input id="reg_password" type="password" /></p>
    
            <p><input type="submit"></p>
        </form>
    </body>
    </html>
    

    Javascript:

    $(document).ready(function() {
    
        $( "#dialog-confirm" ).hide();
    
        $('#reg_form').submit(function() {
    
            $.post( "check_user.php",
                { login: $('#reg_login').val(), password: $('#reg_password').val() },
                function(data) {
                    if(data == 'ok') { // clear inputs
                        $('#reg_login').val('');
                        $('#reg_password').val('');
    
                        $( "#dialog-confirm" ).dialog({
                            resizable: false,
                            height:140,
                            modal: true,
                            buttons: {
                                "Register another": function() {
                                    $( this ).dialog( "close" );
                                    window.location = "http://www.example.com/register";
                                },
                                Cancel: function() {
                                    $( this ).dialog( "close" );
                                    window.location = "http://www.example.com/login";
                                }
                            }
                        });
    
                    } else {
                        // alert('error');
                        $('.error').remove();
                        $('#reg_form').before('<p class="error">Invalid login or password</p>');
                    }
                }
            );
    
            return false;
        });
    });
    

    PHP:

    <?php
        $login = isset($_POST['login']) ? trim($_POST['login']) : '';
        $password = isset($_POST['password']) ? $_POST['password'] : '';
    
        // check login in DB (don't forget to escape...), check password length
        // [...]
        $valid = true; // toggle this to see
    
        echo $valid ? 'ok' : '';
    ?>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm creating a web application which loads tabs using AJAX. My problem is that
I have a problem creating some form of hierarchy with different object types. I
I have a strange problem with native Ajax request invoking. I am creating the
I have a problem with a little .Net web application which uses the Amazon
I have a problem in my project with the .designer which as everyone know
I'm using a simple ajax-enabled WCF service. I'm creating a string of XML on
I have a strange problem creating new counters in existing group. I have a
I have such problem: I'm creating a container and it's content at runtime. Here's
I have a login.jsp page which contains a login form. Once logged in the
Im stuck with a ajax function im creating. Here is the deal, I have

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.