You are viewing limited content. For full access, please sign in.

Question

Question

Disable Submit button if Field value is not 0.0

asked on February 26, 2016 • Show version history

Goal:  Hide the submit button until value of Field46 = 0.0

Field46 gets its value from the SUM of two other fields.  If Field46 is not 0.0, I want the user to modify one of the values in the other field until Field46 changes to 0.0

This is working.

What I cannot get working, is for the submit button to appear after the above has occurred.  I struggle to follow the logic of code, but I am trying.  I copied and slightly modified the following that I found during my research and was hoping someone could direct me as to finish the process.

I am guessing that perhaps the code needs to run again on some function of the page, but I am unsure.

 

$(document).ready(function() {

  //cache the elements we will use
  var $submit = $('.Submit');
  var $Field46 = $('#Field46');

  //hide the submit button
  $submit.hide();

  //bind event handler to the field
  $Field46.change(function() {

    //if the user selects what we want, show the submit button
    if ($Field46.find(':selected').val() === "0.0"){
      
      $submit.show();
    }
    //if not, hide it
    else {
      
      $submit.hide();
    }
  });
});

0 0

Replies

replied on February 27, 2016

Hey, I recognize that code. wink

The reason it's not working for you in this case is because I originally wrote it to check the value of a radio button. From the sounds of it, you're working with a single line or currency field. Try this:

$(document).ready(function() {
    var $submit = $('.Submit');
    $submit.hide();
    $("#Field46").on("change", function() {
        if ($(this).val() == "0.0"){
            $submit.show();
        } else {
            $submit.hide();
        }
    });
});
2 0
replied on February 27, 2016

Websters Dictionary word:  "Awesome"

Definition: answers.laserfiche.com & Ege Ersoz

 

yesThank you very much for both instances of supplying that code.  I am learning, but, because of volunteers like yourself who share and assist ones like me, I was able to keep going without being stonewalled on that relatively smaller part of my project!laugh

0 0
replied on June 17, 2016

Hi,

 

I'm trying to do something similar but can't get it to work.  I want it to evaluate two fields, if they total the same amount them show the Submit button.  It is hiding the Submit button but I can get it to appear again.  Can you help

 

$(document).ready(function(){
var $submit = $('.Submit');
var $Field1 = $('.GROSSAMOUNT');
var $Field2 = $('.GLAMOUNT')

    $submit.hide();

    $('.GLAMOUNT').on('input', 'blur', function() {
        if ($Field1.find('.GROSSAMOUNT input').val() == $Field2.find('.GLAMOUNT input').val()){
            $submit.show();
        } else {
            $submit.hide();
        }

    });  });

0 0
replied on June 14, 2018

I am trying to do something very similar to the original question here.  Only instead of a number value, I am trying to hide the Submit button when a text field (single line) is filled in with a specific value from a look-up table value (in my case, the character string "Expired").  This happens when the user enters a number at the top of the form (and other fields are subsequently populated).  Do I need to modify the code in the first reply a certain way because the value is populated by a look-up?  Any help appreciated!

0 0
replied on April 6, 2020

my case is actually the opposite... can someone verify if this would work accurately?

$(document).ready(function() {
    var $submit = $('.Submit');
    $submit.show();
    $("#q35").on("change", function() {
        if ($(this).val() = "0"){
            $submit.hide();
        } else {
            $submit.show();
        }
    });
});
 

0 0
You are not allowed to follow up in this post.

Sign in to reply to this post.