Expand my Community achievements bar.

OnChange vs OnExit

Avatar

Level 2

Good morning all,

I have this method:

var successFillColor = "204,255,255"; //Aqua

var reqFillColor = "255,255,0"; //Yellow

function validateACESID()

{

        var _Pattern = /^(\d{7})$/;

 

               var entered_text = VisitInformation.PatientInfo_subform.ACESID_TF.rawValue;

 

               if(_Pattern.test(entered_text))

               {

                              unHighlight(VisitInformation.PatientInfo_subform.ACESID_TF);

               }

               else

               {

                              requiredHighlight(VisitInformation.PatientInfo_subform.ACESID_TF);

               }

}

function unHighlight(fld)

{

               fld.fillColor = successFillColor;

}

function requiredHighlight(fld)

{

               fld.fillColor = reqFillColor;

}

When I call this method with "VisitInfo_Validation.validateACESID();" in OnExit it works perfectly, it highlights it yellow when the value is not 7 digits and then highlights it aqua when it is. Now, when I call this method in the OnChange it doesn't catch the true clause of the if statement, only the else.

If anyone can shed some light on this that would be very appreciated, thank you.

james

2 Replies

Avatar

Level 5

James,

When using the change event, try setting your value variable this way:

var entered_text = xfa.event.newText

This should grab the new value within the change event.

I believe rawValue is not updated until after the change event finishes

Avatar

Level 2

I should have mentioned I'm doing this for HTML not PDF.

xfa.event.newText returns undefined unfortunitly.