-3

I am trying to put add a validation condition to a combobox. I have been able to get it to work on other combo boxes, but here I am trying to essentially add 2 validaitons on one combobox. I am not familiar with how the whole validation process works and the order of operation. My code has become convoluted and need help sorting it out.

This is the code on the validation that I am working with:

functionvalidateSLBox(v){
    if(storeSpringLync.findExact('disp',
    v)>-1)returntrue;elsereturn'Notvalid';else{
        if(v=='DC'){
            cbSLBox.enable();
        }else{
            cbSLBox.disable();
        }
    }
}
4

1 に答える 1

0

関数をreturn終了すると、その時点で終了します。関数内のそれ以降は何も実行されないため、関数の後半に到達することはありません。

また、oneelseはただ 1 つに一致しifます。1 つの に対して2 つelseの がありますif

おそらく次のようなものが必要です。

functionvalidateSLBox(v){
  if(v=='DC'){
    cbSLBox.enable();
  }else{
    cbSLBox.disable();
  }

  if(storeSpringLync.findExact('disp',v) > -1){
    return true;
  }else{
    return 'Not valid';
  }
}

これにより、cbSLBox (それが何であれ) を有効にしながら、true または Not valid を返すことができます...これが必要でない場合は、ステートメントを使用するswitchか、if ステートメントをネストすることができます。正確に何をしたいのかによって異なりますが、コードサンプルと説明からはわかりにくいです。

于 2013-11-14T20:41:28.593 に答える