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

Question

Question

Clear Radio Button Value when hidden w/JavaScript

asked on February 23, 2020

Hello, I'm running into a little issue with field rules in Forms and I'm thinking I'll need some JavaScript to assist. 

I have an invoice upload portal that I designed and we're currently having issues with vendors uploading duplicate invoices.  I now have the form run a lookup when the invoice number is input and it populates a message on the form with a radio button "Do you want to cancel your previous submission? (YES / NO) "  Depending on what they select,  a message pops up instructing them what to do.  If they select NO, then the message states we can't accept duplicate invoice numbers and they need to change the invoice number. 

Then, when I change the invoice number, the radio field disappears BUT the message stays and other field rules dependent on that button STAY IN EFFECT.  I have "Ignore the field data" selected in the field rules when that radio button gets hidden but it doesn't seem to be working when other rules are applied.  I think I need javascript to clear that radio button value when a new Invoice number is typed in the Invoice Number field....OR have it cleared whenever it gets hidden....whichever is easier.

Can anyone help me with this?  I'm sure the code is simple but what I've tried so far has had no effect.

Thanks!

0 0

Replies

replied on February 24, 2020 Show version history

I just tested on a simple test process and this should work for you:

$('.invoice-number input').change(function() {
    $('input:radio').attr("checked", false);
});

You would just need to change the selectors to your form.

Note that this will clear EVERY radio button on the form EVERY time the invoice number input changes. If you need to set up more specific rules please post what they are.

0 0
replied on February 24, 2020

Thanks Brian.  I copied that code into my process and it's not working for me.  Is the ".invoice-number" supposed to be the class?  I tried setting my field to that css class and I also tried changing the identifier to use #q1 which is the field ID for Invoice Number but it still isn't working.

$('#q1 input').change(function() {
    $('input:radio').attr("checked", false);
});

0 0
replied on June 12, 2020

Grant,

I'm having the same problem as you. Were you ever able to find a solution? 

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

Sign in to reply to this post.