0
我有一個使用mailchimp的訂閱表單。阻止使用jQuery提交HTML表單
我已經寫了一個JS驗證方法來阻止hotmail/yahoo/gmail帳戶註冊只有我不能得到它的工作?不管試了一下香港專業教育學院的形式作用踢和JS被忽略......
表單標籤
<form id="mc-embedded-subscribe-form" class="validate" action="action here" method="post" name="mc-embedded-subscribe-form" novalidate="" target="_blank">
JS驗證
$('#mc-embedded-subscribe-form').on('submit', function (e) {
var inputString = $('#mce-EMAIL').val();
var gmail = "gmail";
var yahoo = "yahoo";
var hotmail = "hotmail";
if (inputString.indexOf(gmail) > -1) {
alert('Sorry, Gmail accounts are unable to subscribe');
return false;
} else if (inputString.indexOf(yahoo) > -1) {
alert('Sorry, Yahoo accounts are unable to subscribe');return false;
} else if (inputString.indexOf(hotmail) > -1) {
alert('Sorry, Hotmail accounts are unable to subscribe'); return false;
} else {
return true;
}
});