2015-08-08 56 views
1

我想设置我的html的自定义验证消息形成正确显示第一个消息,但是当我在文本框中再次输入一个值,该消息仍然显示挡住了我提交的Html oninvalid循环本身

oninvalid="setCustomValidity('Plan for goals is required')" 
+0

难道你需要手动将setCustomValidity在某些时候重新设置为空字符串? –

+0

@UlrichSchwarz无法获得您的密码 –

+0

如果我[MDN](https://developer.mozilla.org/en-US/docs/Web/Guide/HTML/HTML5/Constraint_validation) setCustomValidity(“Plan ...”)',你已经将该字段标记为无效,直到你设置了它的setCustomValidity(“”)。 –

回答

1

required应该在输入标签的结束,这里是你的代码应该如何看起来像:

<input type="number" min="30" max="300" oninvalid="setCustomValidity('Plan for goals is required');" style="width:130px;" class="btn btn-default state" data-style="btn-default" ng-model="userlifestyle.goalSet.wkplans" ng-init="userlifestyle.goalSet.wkplans='@plannedWkDayForGoal'" required></input> 
+0

类型是数字,我不想在这里有任何模式 –

+0

嗯,好吧。我只是用一个数字尝试过,而且效果很好。我会明白你为什么会得到这个错误。 –

+0

你能展示更多的代码吗? –