Simple Java task on text box

clear a form field when typing in another field.

Overview

The inline onkeydown event handler in a custom code field was not executing properly within the CF form structure.
Use a Load JavaScript action with jQuery to attach a keydown event listener to the source field that sets the value of the target field to empty.

Answered
ks ksignorello 28 May, 2015
On a new form I have a simple task. When the user start typing in one field the contents of another fiend should be wiped out.

I made the field a custom code field:

<input id="ExhibitDesiredPrice" class="validate['digit','nospace'] form-control A" title="" maxlength="" name="ExhibitDesiredPrice" size="5" type="text" onkeydown="this.form.ExhibitDesiredNet.value=''" placeholder="If not for sale - enter 0" data-inputmask="" data-load-state="" data-tooltip="" />

Doesn't seem to work. I'm doing the same thing on a manually created non chronoform form - but I'd love to replace it with a chronoform.

Do you see anything I'm doing wrong? Or is there something special I need to do to get it work in chronform 5.

Ken
Gr GreyHead 29 May, 2015
Answer
1 Likes
Hi Ken,

Using jQuery in a Load JavaScript action please try this
jQuery(document).ready(function (jQ) {
  jQ('#ExhibitDesiredPrice').on('keydown', function() {
    jQ('#ExhibitDesiredNet').val('');
  });
});
!! not tested and may need debugging !!

Bob
ks ksignorello 29 May, 2015
That worked! I'm on my way! Enjoy the beer!

Ken
This topic is locked and no more replies can be posted.