浏览代码

fix issue with regex form tooltip

Jason Rivard 6 年之前
父节点
当前提交
e1096a7c8c
共有 1 个文件被更改,包括 5 次插入4 次删除
  1. 5 4
      webapp/src/main/webapp/WEB-INF/jsp/fragment/form.jsp

+ 5 - 4
webapp/src/main/webapp/WEB-INF/jsp/fragment/form.jsp

@@ -201,10 +201,11 @@
             <script type="text/javascript">
             <script type="text/javascript">
                 PWM_GLOBAL['startupFunctions'].push(function(){
                 PWM_GLOBAL['startupFunctions'].push(function(){
                     PWM_MAIN.addEventHandler('<%=loopConfiguration.getName()%>', 'input', function (event) {
                     PWM_MAIN.addEventHandler('<%=loopConfiguration.getName()%>', 'input', function (event) {
-                        event.target.setCustomValidity("");
-                    });
-                    PWM_MAIN.addEventHandler('<%=loopConfiguration.getName()%>', 'invalid', function (event) {
-                        event.target.setCustomValidity('<%=StringUtil.escapeJS(loopConfiguration.getRegexError(formLocale))%>');
+                        var input = event.target;
+                        var regexError = '<%=StringUtil.escapeJS(loopConfiguration.getRegexError(formLocale))%>';
+                        var msg = input.value.search(new RegExp(input.getAttribute('pattern'))) >= 0 ? '' : regexError;
+                        input.setCustomValidity(msg);
+                        input.title = msg;
                     });
                     });
                 });
                 });
             </script>
             </script>