【发布时间】:2018-11-28 02:10:57
【问题描述】:
我遇到的问题实际上甚至可以在此处的官方 SmartGWT 演示中看到:https://www.smartclient.com/smartgwt/showcase/#form_validation_regexp
如果您不输入任何内容(将字段留空)并按验证,则不会显示任何错误。对于必填值,即使字段为空,我也需要显示错误。
我将验证器设置为:
RegExpValidator regExpValidator = new RegExpValidator();
regExpValidator.setExpression("^[0-9A-Z_]{7,12}$");
regExpValidator.setErrorMessage("Code must contain capital letters and numbers");
codeField.setValidators(regExpValidator);
现在这个表达式不匹配一个空字符串。然而,我在验证时没有收到任何错误。
如何在表单中显示空必需值的错误?
【问题讨论】: