2014-07-22 64 views
0

我尝试创建过滤器编号:textBox过滤器的值只接受编号。 你能帮助我,请 过滤器接受int或FLOAD不是int VAR我尝试创建过滤器编号

function callok(e){ var app = UiApp.getActiveApplication(); var montantEE = e.parametre.MontantEE; if (montantEE==number){app.getElementById('validateLabel').setText('PleaseMontant !'); }else{ app.getElementById('validateLabel').setText('You entered: '+ e.parametre.MontantEE); return app;

回答

0

不完全相信我的理解正是你的要求,但我建议你使用再加上ClientHandler的验证程序,以达到什么你需要。

只需将一个integer-validator添加到客户端处理程序,该客户端处理程序将启用您可能用于提交值的按钮。使用非整数验证器来确保处理任何打字校正。

这里是一个例子代码和test app online

var app = UiApp.createApplication().setTitle('test sidebar'); 
    var panel = app.createVerticalPanel(); 
    var btn = app.createButton('submit').setEnabled(false); 
    var inputBox = app.createTextBox().setName('num'); 
    var cHandler1 = app.createClientHandler().validateInteger(inputBox).forTargets(btn).setEnabled(true).forEventSource().setStyleAttribute('backgroundColor','lightgreen'); 
    var cHandler2 = app.createClientHandler().validateNotInteger(inputBox).forTargets(btn).setEnabled(false).forEventSource().setStyleAttribute('backgroundColor','red'); 
    inputBox.addKeyUpHandler(cHandler1).addKeyUpHandler(cHandler2); 
    panel.add(inputBox).add(btn); 
    return app.add(panel);