decimalbox输入框限制大小问题

xiaopeix 2014-04-14 11:38:19
页面上有个<decimalbox width="10%"/>栏位,想要实现限制整数部分不能大于十位数,小数点后面部分不限制,不能在栏位框里限制用maxlength,这样会导致整个输入不能大于十位数,小数点部分也包括进去。
问题:我现在只想要限制整数部分的长度或者可以限制整个输入的大小小于11位数,请帮帮忙,谢谢了
...全文
150 10 打赏 收藏 转发到动态 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
tony4geek 2014-04-14
  • 打赏
  • 举报
回复
tony4geek 2014-04-14
  • 打赏
  • 举报
回复
<decimalbox format="###.##" value="154.326" width="150px" />
tony4geek 2014-04-14
  • 打赏
  • 举报
回复
正则format 下。
tony4geek 2014-04-14
  • 打赏
  • 举报
回复
上面类似。 我也是刚看这个zk 好像很强大啊。 你的那个 看看这个可以不
xiaopeix 2014-04-14
  • 打赏
  • 举报
回复
引用 8 楼 rui888 的回复:
参考
这里面并没有实现我需要的decimalbox的这个问题啊
tony4geek 2014-04-14
  • 打赏
  • 举报
回复
xiaopeix 2014-04-14
  • 打赏
  • 举报
回复
引用 5 楼 rui888 的回复:
请问这个能不能在客户端就进行验证,不跑后台
tony4geek 2014-04-14
  • 打赏
  • 举报
回复
上面地址不是给你了。里面有验证的 。 正则表达式约束仅适用于字符串类型组件,例如textbox、combobox和bandbox。 你那个 自己写 ,
public class FormValidator extends AbstractValidator {
     
    public void validate(ValidationContext ctx) {
        //all the bean properties
        Map<String,Property> beanProps = ctx.getProperties(ctx.getProperty().getBase());
         
        //first let's check the passwords match
        validatePasswords(ctx, (String)beanProps.get("password").getValue(), (String)ctx.getValidatorArg("retypedPassword"));
        validateAge(ctx, (Integer)beanProps.get("age").getValue());
        validateWeight(ctx, (Double)beanProps.get("weight").getValue());
        validateEmail(ctx, (String)beanProps.get("email").getValue());
        validateCaptcha(ctx, (String)ctx.getValidatorArg("captcha"), (String)ctx.getValidatorArg("captchaInput"));
    }
     
    private void validatePasswords(ValidationContext ctx, String password, String retype) { 
        if(password == null || retype == null || (!password.equals(retype))) {
            this.addInvalidMessage(ctx, "password", "Your passwords do not match!");
        }
    }
     
    private void validateAge(ValidationContext ctx, int age) {
        if(age <= 0) {
            this.addInvalidMessage(ctx, "age", "Your age should be > 0!");
        }
    }
     
    private void validateWeight(ValidationContext ctx, double weight) {
        if(weight <= 0) {
            this.addInvalidMessage(ctx, "weight", "Your weight should be > 0!");
        }
    }   
     
    private void validateEmail(ValidationContext ctx, String email) {
        if(email == null || !email.matches(".+@.+\\.[a-z]+")) {
            this.addInvalidMessage(ctx, "email", "Please enter a valid email!");            
        }
    }
     
    private void validateCaptcha(ValidationContext ctx, String captcha, String captchaInput) {
        if(captchaInput == null || !captcha.equals(captchaInput)) {
            this.addInvalidMessage(ctx, "captcha", "The captcha doesn't match!");
        }
    }
     
}
xiaopeix 2014-04-14
  • 打赏
  • 举报
回复
引用 2 楼 rui888 的回复:
<decimalbox format="###.##" value="154.326" width="150px" />
format是格式吧,并不能对输入进行限制

81,092

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧