我在我的HTML如下形式不工作:香菜JS:表單驗證密碼字段(MINLENGTH個)如預期
<form action="" method="POST" accept-charset="utf-8" data-parsley-validate >
<fieldset>
<legend>Parsely JS Testing</legend>
<input type="" name="Full Name" placeholder="Full Name" data-parsley-pattern="[a-z|A-Z]" data-parsley-trigger="focusin focusout" data-parsley-error-message="You need to enter your full name" data-parsley-errors-container="#error-container">
<input type="" name="Phone" placeholder="Phone" data-parsley-type="digits" data-parsley-min="10" data-parsley-trigger="focusin focusout" data-parsley-error-message="Enter valid phone number" data-parsley-errors-container="#error-container">
<input type="" name="Email" placeholder="Email" data-parsley-type="email" data-parsley-trigger="focusin focusout" data-parsley-error-message="Enter Valid Email" data-parsley-errors-container="#error-container">
<input type="" name="password" placeholder="Password" data-parsley-type="alphanum" data-parsley-min="7" data-parsley-trigger="focusin focusout" data-parsley-error-message="Password must be atleast 7 characters" data-parsley-errors-container="#error-container" id="password">
<input type="" name="confirmpassword" placeholder="Confirm Password" data-parsley-trigger="focusin focusout" data-parsley-error-message="Password Does not match" data-parsley-errors-container="#error-container" data-parsley-equalto="#password">
</fieldset>
<button type="submit">SUBMIT</button>
</form>
我使用parsely.js來驗證這種形式,我有一個輕微驗證密碼域的問題。我有密碼費爾德以下HTML:
<input type="" name="password" placeholder="Password" data-parsley-type="alphanum" data-parsley-min="7" data-parsley-trigger="focusin focusout" data-parsley-error-message="Password must be atleast 7 characters" data-parsley-errors-container="#error-container" id="password">
域的驗證上focusin
和focusout
,像這樣:
data-parsley-trigger="focusin focusout"
爲了驗證我有2個規則,如下:
data-parsley-type="alphanum"
和
data-parsley-min="7"
條
這兩個規則似乎並不在串聯是工作得非常好,所以如果我輸入下面的密碼:
gautam007
我得到的#error-container
一個錯誤,錯誤得到的是我在進入一個錯誤消息數據屬性。
data-parsley-error-message="Password must be at least 7 characters"
爲什麼我得到這個錯誤,我該如何解決這個問題?