【问题标题】:How to dynamically change validators at runtime如何在运行时动态更改验证器
【发布时间】:2015-06-19 00:51:41
【问题描述】:

假设我在一个字段中进行了此验证:

之间: { 分钟:50, 最大:500, message: '请输入正确的范围' }

我想在运行时更新minmax。 我该怎么做?

谢谢。

【问题讨论】:

    标签: formvalidation-plugin


    【解决方案1】:

    您可以使用updateOption 方法来做到这一点。

    见以下代码:

    $('#yourForm')
        // Update min & max options
        .formValidation('updateOption', 'yourInputName', 'between', 'min', 10)
        .formValidation('updateOption', 'yourInputName', 'between', 'max', 90)
    
        // Update message if you need to
        .formValidation('updateOption', 'yourInputName', 'between', 'message', 'Your new message')
    
        // You might need to revalidate field
        .formValidation('revalidateField', 'yourInputName');
    

    # 工作示例:

    # 参考:

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多