0
我的第一篇文章!jquery模式匹配轉義不顯示自定義錯誤消息
我一直在努力與基本上都是用於建築2 jQuery的變量:
- 確保正則表達式模式之後
- 比較領域,而不是提交直到都匹配。
它加載HTML中的第一場改變和第二動態添加:
$('#pass').on('input', function() {
$("#pass").replaceWith(ba);
$("#prd").html('New Account Password<span class="small">Your New Account Password</span>');
$("#pass").focus();
var newTextBoxDivc = $(document.createElement('div')).attr({
"id": "TextBoxDivc"
}).css({
"display": "inline",
"position": "relative"
});
newTextBoxDivc.after().html(bb);
newTextBoxDivc.appendTo("#op");
});
var bb = ("<label>Confirm New Password</label><span class='small'>Confirm Your New Password</span><input type='text' name='passa' id='passa' required pattern='(?=.*\\d)(?=.*[a-z])(?=.*[A-Z])\\w{6,20}' onchange='this.setCustomValidity(this.validity.patternMismatch ? \'Your passwords do not match please enter the same password as above\' : \'\');' oncopy='return false' onpaste='return false' autocomplete='off' autocorrect='off'>");
var ba = ("<input type='text' name='pass' id='pass' required pattern='(?=.*\\d)(?=.*[a-z])(?=.*[A-Z])\\w{6,20}' oncopy='return false' onpaste='return false' autocomplete='off' autocorrect='off' onchange='this.setCustomValidity(this.validity.patternMismatch ? \'To create a strong password for your account use a mix of at least 6 characters that includes at least one UPPERCASE letter (A-Z) and at least one number (0-9)\' : \'\'); if(this.checkValidity()) formEley.passa.pattern = this.value;'>");
JFiddle說的代碼是罰款,按提交按鈕時,它說:「你必須使用此格式」 ...所以檢查模式似乎沒問題......但它不顯示自定義錯誤消息。
在過去的4個小時裏,我一直拉着我的頭髮。
任何和所有幫助最受歡迎!!!!
http://jsfiddle.net/JamesMarz/db1qa83f/
如果你有一個JSFiddle,然後鏈接它! – elzi 2014-11-06 23:11:15
我沒有jsfiddle帳戶。剛剛在那裏測試了核心代碼。試圖打開一個,因爲你的帖子,但它似乎有問題,他們的註冊。不停地告訴我有人的郵件已經註冊,我不是,然後當我嘗試重置密碼說它沒有帳戶!??! AArrrggghhh ... – James 2014-11-06 23:21:58
http://jsfiddle.net/JamesMarz/db1qa83f/ – James 2014-11-06 23:30:25