getSelectedIndex() == -1 even when typing in Correct Value

Hello!
I am using several combo boxes in one form, initiated as filters:

var z=new dhtmlXCombo(comboid,“alfa1”,200);
z.enableFilteringMode(true);

I need to validate each combo box upon submit and upon moving away. I am successfully using this code in both situations (I am using a similar one for the Submit event):

z.attachEvent(“onBlur”, onBlurFunc);

function onBlurFunc(){
if (z.getSelectedIndex() == -1){
//MESSAGE TO DO SOMEHTING
}
}

The problem I have is when the user types an incorrect value, moves away, presented with my message to fix the value, returns back to the combo field, and TYPES IN the correct value. The user in such case does not necessarily SELECTS the option value. In case the users moves away after he/she typed the CORRECT value, the combo is still recognizing this values with (z.getSelectedIndex() == -1), even though the underlying hidden input box “alfa1” finds the correct value (for example, “20”, corresponding to the index of the option).

When users returns back and SELECTS the same value from the option drop=down - the z.getSelectedIndex() is recognizing the correct option.

What needs to be done in order to recognize the correct Index of the value when the users TYPES into the box?

Thank you a lot!

Hello,

try to use the different check - whether a combo contains an option with submitted value:

function onBlurFunc(){ var value = this.getActualValue(); if( !this.getOption(value) ){ //MESSAGE TO DO SOMEHTING } }

Thank you! That works very well!

Anya