Jquery html5验证和错误消息
我需要根据输入错误显示错误消息。我做错了什么?
I need to show the error message based on input error. what I'm doing wrong?
当h5validation添加类时也应该显示错误.ui-state-error
also the error should be displayed when the h5validation adds the class .ui-state-error
if($(。ui-state-error)。is(:visible)== true){find errors and display input:email
if ($(".ui-state-error").is(":visible") == true) { find errors and display input:email
<section class="errors">
<p class="email"><span>Please enter a valid Email.</span></p>
<p class="password"><span>Please re-type your password.</span> Your passwords didn't match.</p>
<p class="repeat-password"><span>Please re-type your password.</span> Your passwords didn't match.</p>
</section>
你需要做的第一件事看看如何调用 .live()方法。 .live()
不接受函数作为第一个参数,它将您希望它作为第一个参数监听的事件和作为第二个参数的函数接收,所以这可能会给你带来一些麻烦。此外,由于jQuery 1.7, .live()
已弃用,而支持 .on()
。
The first thing you need to take a look at is how you call the .live() method. .live()
does not take a function as the first parameter, it takes the event you want it to listen for as the first parameter and the function as the second paramter, so that will likely cause you some trouble. Also, since jQuery 1.7, .live()
is deprecated in favor of .on()
.
如果你想在提交时调用该函数,这可能是最常见的,那么你应该使用 .submit()
而不是 .live()
。
If you want the function to be called on submit, which is probably the most common, then you should use .submit()
instead of .live()
.