Javascript event handlers question

Javascript event handlers question

divad.thgirbladivad.thgirbla Posts: 27Questions: 10Answers: 0

I'm trying to use a javascript onchange() event handler on my Editor fields. Specifically, numeric fields so that I can check that the values meet certain criteria. The field definition looks like this:

{label: 'W2', name: 'W2_Amount', id: 'W2_Amount', type: 'text', attr:{onchange:'myChange(this)',classname:'numericField2',type:'number',maxlength:13, min:'0', max:'99999999', step:'0.01'} }

The onchange() event handler executes when the field value changes, which is what I want, but it also executes when the Editor page first displays for every field that has an onchange() event handler, which is what I don't want. My guess is that the initial page load's values go from uninitialized to a value, triggering the event handler for each field, when the page loads. Is there a way to bypass the initial triggering on a page load? Or should I be handling event handlers a different way?

This question has an accepted answers - jump to answer


  • colincolin Posts: 8,013Questions: 0Answers: 1,348
    Answer ✓

    I'd be tempted to use dependent() instead of onchange() - it will get triggered only on a change, and will be within Editor.

    If you use onchange(), I'd imagine you would need to remove the exiting triggers in preClose, and re-add again once the form is fully opened and the data present in the opened,


  • divad.thgirbladivad.thgirbla Posts: 27Questions: 10Answers: 0

    Using the dependent() function helped solve this issue.


Sign In or Register to comment.