0
我有一些輸入字段,我想直接驗證爲用戶鍵入如何驗證上改變輸入字段,並啓用提交按鈕
輸入字段綁定到特定的條件雖然。
這裏是例子:
<input type="text" data-type="inputFullName" />
<br />
<input type="text" data-type="inputEmail" />
<br />
<input type="text" data-type="inputPhone" />
<br/>
<input type="checkbox" id="chkbox" />
<label>Check here</label>
<br />
<button id="button1" disabled>Click</button>
而且JS:
$('input').on('keyup change', function() {
$('#button1').prop('disabled', $('input[data-type="inputFullName"]').val() == '' || $('input[data-type="inputEmail"]').val() == '' || $('input[data-type="inputPhone"]').val() == '' || !$('input[type="checkbox"]').is(':checked'))
});
到目前爲止好,但我怎麼能檢查:
1)用戶輸入全名(first + lastname)
2)電子郵件實際上是一種電子郵件
3) PHONENUMBER長
8號。我有一個JSFiddle
任何幫助表示讚賞。
您正在尋找'first + lastname'的模式? – Rayon
您的3個問題在stackoverflow中有大量重複項。 **使用搜索引擎**,不要爲無盡的重複這些簡單的任務。 –
@RayonDabre模式應該是基本的,比如'我的名字',還有'我的名字'或'我的別名' – Steve