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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T00:44:28+00:00 2026-06-02T00:44:28+00:00

I am Submiting form through MOUSE CLICK and ENTER too. Ajax Call is checking

  • 0

I am Submiting form through MOUSE CLICK and ENTER too.

Ajax Call is checking is there any designation which i already in DATABASE.. If not, user can submit form otherwise SUBMIT button will DISABLE

JQUERY

function check_designation(e){

    text = $('#req1').val();
    data = "data=" + text;          
    text_length = text.length           

    if(text_length == 0)
    {
        $('#result_span').html('');
    }       

    if(text_length > 3 ){
        $.ajax({
            url: "designation_ajax.php",
            type: "POST",
            data: data,    
            cache: false,
            success: function (response) {
                if ($.trim(response) == "access") { 
                    $("#result_span").html('<div class="green">' + text + ' is available '+'</div>');
                    $('#create_desg').removeAttr('disabled');
                }
                else if ($.trim(response) == "no access") {                                                         
                    $("#result_span").html('<div class="red">' + text + ' is already in use'+'</div>'); 
                    $('#create_desg').attr('disabled','disabled');                                                      
                }

                else { 

                    alert('Sorry, unexpected error. Please try again later.');

                }
            }      
        }); 
    }
    else{
        $("#result_span").html('');     

    }

    return true;        
}

HTML FORM

<form id="formID" class="formular" method="POST" action="" onsubmit="formSubmit()" >
  <fieldset>
    <legend>Create Desination</legend>
    <label> Designation<br clear="all" />
      <input autocomplete="off" onkeyup="check_designation(event)" value="" class="validate[required,minSize[4]] text-input float_left" type="text" name="name" id="req1" />
      <span id="result_span"></span>
    </label>
    <br clear="all" />
    <input id="create_desg" value="Submit" type="button" />
  </fieldset>
</form>

PROBLEM::::

Now what happen DISABLE button is not a solution… if there is already a DESIGNATION in a table.. submit button will disable but By ENTER it will submitted and i dont want to reload the page. and AJAX is not working when i PRESS ENTER

  • 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-06-02T00:44:29+00:00Added an answer on June 2, 2026 at 12:44 am

    You must return false from your onsubmit handler in order to cancel the default action. But I would probably clean your code a bit and subscribe to the submit event unobtrusively:

    <form id="formID" class="formular" method="POST" action="">
        <fieldset>
            <legend>Create Desination</legend>
            <label>
                Designation<br clear="all" />
                <input autocomplete="off" value="" class="validate[required,minSize[4]] text-input float_left" type="text" name="name" id="req1" />
                <span id="result_span"></span>
            </label>
            <br clear="all" />
            <input id="create_desg" value="Submit" type="button" />
        </fieldset>
    </form>
    

    You will notice that I have intentionally removed the onkeyup event from the input field. Hammering your server with AJAX requests every time some user hits a key while inside this field won’t do any good to your server. If you want to implement this I would recommend you waiting for some input to accumulate and throttle before sending the AJAX request.

    and then:

    $(function() {
        $('#formID').submit(function() {
            var text = $('#req1').val();
            if(text.length == 0) {
                $('#result_span').html('');
            }       
    
            if(text.length > 3) {
                $.ajax({
                    url: 'designation_ajax.php',
                    type: 'POST',
                    data: { data: text },
                    cache: false,
                    success: function (response) {
                        if ($.trim(response) == 'access') { 
                            $('#result_span').html('<div class="green">' + text + ' is available '+'</div>');
                            $('#create_desg').removeAttr('disabled');
                        }
                        else if ($.trim(response) == 'no access') {
                            $("#result_span").html('<div class="red">' + text + ' is already in use'+'</div>'); 
                            $('#create_desg').attr('disabled', 'disabled');
                        } else { 
                            alert('Sorry, unexpected error. Please try again later.');
                        }
                    }      
                }); 
            } else {
                $('#result_span').html('');     
            }
    
            // return false to prevent the default action
            return false;
        });
    });
    

    Also I would have the designation_ajax.php script return JSON instead of some access and no access strings that you are parsing and trimming in your success callback.

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

Sidebar

Related Questions

I'm submitting a form using an ajax request (POST method), and checking the HTTP
I'm uploading a file using jQuery through Ajax. I'm submitting some form elements also,
So I have a form and I'm submitting the form through ajax using jquery
i m using asp.net mvc2 and i m submitting a form through ajax using
I'm developing this app which as a very basic Ajax form and I'm currently
In my application am submiting my form by using post for a php page.
I am getting Error in submitting the form using AJAX and Jquery, following is
Say, you are submitting a form, which affects your database (adding records/ deleting them/
On my forms I prevent the user from submitting the form by clicking enter
Can anyone help with this strange form submiting in FireFox? So this form should

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.