简体   繁体   中英

Angular-Xeditable e-pattern not accepting valid regular expression

I am trying to validate the user input of a text field using e-pattern from the angular-xeditable directive. I have built the regular expression using an online regex builder/tester and it does exactly what I want however angular-xeditable doesn't seem to recognize the expression as being valid. It shows the below even when the expression is valid.

requirements:

  • Value must be >= 0.0 or <= 1.0
  • Value can have one or two decimal places
  • First decimal place can be a digit between 0-9
  • Second decimal place should be either 0 or 5

valid entry: 0.5, 0.95, 0.40, 1.0

regex:

 ^((0+(\.[0-9][05]?))|1+(\.0))$

code:

<span e-pattern="/^((0+(\\.[0-9][05]?))|1+(\\.0))$/" e-required ng-show="!tableform.$visible" editable-text="user.available" e-form="tableform" onbeforesave="checkAvailable($data)">{{ user.available}} </span>

message:

在此处输入图片说明

Is there anything I'm missing or need to amend to the expression or span tag?

失败了,我只是想出了一个问题,它非常简单的电子模式在表达式之前或之后不需要/ ^或$ /,应改为:

 e-pattern="((0+(\.[0-9][05]?))|1+(\.0))"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM