2016-11-09 42 views
0

我目前正在对针叶林的自定义实现,我注意到的是,即使我们在app/partials/custom-attributes/custom-attribute-value-edit.jade置于一种模式,我们的自定义输入区如果输入没有按来ping错误不按照指定的模式如此大雅前端提交的自定义属性更改即使无效

input#custom-field-value(name="value", type="tel", pattern="^\\+\\d{1,3}\\s\\d{1,3}\\s\\d{3}\\s\\d{4}$", placeholder="format: +[country_code] [area_code] [xxx] [xxxx] (e.g: +1 234 567 8910)", value!="<%- value %>") 

表格仍然提交给后端。虽然我确实看到一条表示模式不匹配的快速消息,但表单仍然提交。我得到了追查的过程中最远的是这个文件 app/coffee/modules/common/custom-field-values.coffee

有一部分没有用于处理提交

submit = debounce 2000, (event) => 
     event.preventDefault() 

     form = $el.find("form").checksley() 
     return if not form.validate() 

     input = $el.find("input[name=value], textarea[name='value'], select[name='value']") 
     attributeValue.value = input.val() 
     if input.prop("type") == 'checkbox' 
      if input[0].checkValidity() 
       attributeValue.value = !!input.prop("checked") 

但那是据我得到了。我的目标是不允许提交如果没有按照指定的模式输入验证问题,如输入发生。我使用的针叶林是3.0.0

回答

0

的当前版本我想它最终会。 Taiga使用checksley进行表单验证。代替使用“模式”为我的正则表达式像一个正常的输入字段验证,我使用checksley的属性数据的regexp。这处理了我需要的验证。

input#custom-field-value(name="value", type="tel", data-regexp="^\\+\\d{1,3}\\s\\d{1,3}\\s\\d{3}\\s\\d{4}$", placeholder="format: +[country_code] [area_code] [xxx] [xxxx] (e.g: +1 234 567 8910)", value!="<%- value %>") 

的文档可以在下面的链接

https://media.readthedocs.org/pdf/checksley/latest/checksley.pdf

找到
相关问题