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 7612909
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T02:02:13+00:00 2026-05-31T02:02:13+00:00

i just pluged a JQuery username check which worked fine , the problem is

  • 0

i just pluged a JQuery username check which worked fine , the problem is that my form still submitting even the username exist on my Mysq Database, how can i configure it to deny submitting to my server side .php file if it exists ?

here is my Jquery plugin javascript code

  $(document).ready(function() {


        //the min chars for checkusername
        var min_chars = 3;

        //result texts
        var characters_error = 'Minimum amount of chars is 3';
        var checking_html = '<img src="images/checkusername.gif" /> Checking...';

        //when button is clicked
        $('#check_checkusername_availability').click(function(){
            //run the character number check
            if($('#checkusername').val().length < min_chars){
                //if it's bellow the minimum show characters_error text
                $('#checkusername_availability_result').html(characters_error);
            }else{          
                //else show the cheking_text and run the function to check
                $('#checkusername_availability_result').html(checking_html);
                check_availability();
            }
        });


  });

//function to check checkusername availability  
function check_availability(){

        //get the checkusername
        var checkusername = $('#checkusername').val();

        //use ajax to run the check
        $.post("frontend/functions/f_checkuser.php", { checkusername: checkusername },
            function(result){       
                //if the result is 1
                if(result == 1){
                    //show that the checkusername is available
                    $('#checkusername_availability_result').html('<span class="is_available"><b>' +checkusername + '</b> is Available</span>');
                }else{
                    //show that the checkusername is NOT available
                    $('#checkusername_availability_result').html('<span class="is_not_available"><b>' +checkusername + '</b> is not Available</span>');
                }
        });

} 

here is my html field

 <table border="0" >
          <tr>
            <td valign="middle"><input class="input_field_12em required userUserName" name="userUserName" id="checkusername"></td>
            <td valign="middle"><input type='button' id='check_checkusername_availability' value='Check Availability'></td>
            <td><div id='checkusername_availability_result'></div></td>
          </tr>
        </table>
  • 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-31T02:02:14+00:00Added an answer on May 31, 2026 at 2:02 am

    You can wait for the callback to fire for your AJAX request, then you can either submit the form or not:

    $(function () {
        $('form').on('submit', function (event, extra) {
            if (typeof extra == 'undefined') {
                extra = false;
            }
            //if no extra argument is passed via `.trigger()` then don't submit the form
            return extra;
        });
        $('#check_checkusername_availability').on('click', function () {
            $.ajax({
                url : 'frontend/functions/f_checkuser.php',
                type : 'post',
                data : { checkusername : $('#checkusername').val() },
                success : function (serverResponse) {
                    //now check the serverResponse variable to see if the name exists, if not then run this code:
                    $('form').trigger('submit', true);
                },
                error   : function (jqXHR, textStatus, errorThrown) { /*don't forget to handle possible errors*/ }
            });
        });
    });
    

    Otherwise, you can force the AJAX request to be synchronous by setting async:false, but this will lock-up the browser until the AJAX request resolves, which could be seconds where the user can’t do anything. This gives the impression that your script is broken to the user.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Just looking for the first step basic solution here that keeps the honest people
Just how much slower are events? I have written a streaming XML parser (that
Is there any way that java can detect that I have just plugged in
Just what the title says, I need to change the password for an existing
just a quick question: I am a CS undergrad and have only had experience
Just bought a 2.4GHz Intel Core 2 Duo iMac with 2GB of memory and
Just getting my head around Ruby metaprogramming. The mixin/modules always manage to confuse me.
just wondering if anyone knows of a truly restful Put/delete implementation asp.net mvc preview
Just installed the latest SDK for iPhone 2.1. When I go to File ->
Just like it reads.

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.