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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T17:59:53+00:00 2026-05-25T17:59:53+00:00

Hands up – I can’t figure it out what’s wrong with it. Is that

  • 0

Hands up – I can’t figure it out what’s wrong with it. Is that a bug or a wrong code ?

    $(document).ready(function() {
    $("#rem_but").click(function(){

    var mail_name = $("#mail_rem").val();
    var dataString = 'mail_name='+ mail_name;


    if (mail_name.val() == "") {  $("#rem_but").attr("disabled",true); } 
    else {  $("#rem_but").removeAttr("disabled"); };
}); });

So when there’s no input the button returns false correctly – when there’s an input in the field – still the button returns false, hence the removeAttr() doesn’t work – why ? Regards.

  • 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-25T17:59:54+00:00Added an answer on May 25, 2026 at 5:59 pm

    Are you using jQuery 1.6.x?

    If so then you should try using the .prop() function. See below:

    Disable/enable an input with jQuery?

    Also, in your if statement no need to keep selecting $("#rem_but"). Based on your code I would recommend $(this) instead –

    $(this).prop('disabled', true);
    

    This should work –

    $(document).ready(function() {
     $("#rem_but").click(function(e) {
    
     e.preventDefault();
    
     var mail_name = $.trim($("#mail_rem").val());
     var dataString = 'mail_name='+ mail_name;
    
     if (mail_name === "") {  
        $(this).prop("disabled", true); }
     else {  
        $(this).prop("disabled", false); }
     });
    });
    

    Here is the working jsFiddle code –

    http://jsfiddle.net/4rPc5/

    Updated code –

    http://jsfiddle.net/4rPc5/2/

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

Sidebar

Related Questions

I tired my hands on bazaar(launchpad), for the reason that i can host my
I have an object factory that hands out instances of a few constant, immutable
I have a bunch of code that hands over stuff from a logged in
I'm looking to get my hands on an API (hopefully one that's platform agnostic)
I am trying hands on one code in C where in I need to
I've been getting my hands wet with emacs lisp, and one thing that trips
So as it stands I have a form that hands a file to my
I am getting my hands on MVC 3 and am confused that how do
I am trying my hands on Spring tool suite. I observed that it when
I wrote this code to get my hands working on the system calls. I

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.