0
如何驗證郵件上使用javascript時,服務器端無法驗證客戶端?從我的理解中,Javascript可以關閉,那麼如何實現這一點,並防止我接收PCI警告?
$(document).ready(function() {
var clearMePrevious = "";
// clear input on focus
$("#email").focus(function() {
if($(this).val()==$(this).attr("title")) {
clearMePrevious = $(this).val();
$(this).val("");
}
});
// if field is empty afterward, add text again
$("#email").blur(function() {
if($(this).val()=="") {
$(this).val(clearMePrevious);
}
});
$('#submitemail').click(function() {
app.ajax.load({
reqName : 'emailSubmit',
url: '$httpUrl('Bronto-OptIn')$?email=' + $('#email').val(),
selector : '#emailbox',
callback: function(responseText, textStatus) { }
});
return false;
});
});
<form id="emailsignup_form" name="emailsignup_form" method="post" action="$httpUrl('Bronto-OptIn', 'fid', 'information')$">
<div class="fl"><input class="email-signup-input" type="text" title="Enter Your Email Address" value="Enter Your Email Address" name="email" id="email" /></div>
<div class="fl"><button class="email-signup-btn" value="Submit" name="submitemail" id="submitemail">Submit</button></div>
<div class="clear"> </div>
爲什麼能」服務器驗證?無論你做什麼,客戶端驗證都是不安全的。 – elclanrs
不完全瞭解你的問題。您可以使用正則表達式驗證客戶端(類似於** ^。+ @。+(\ .. +)+ $ **)。但是,如果用戶禁用JavaScript,您總是希望再次在服務器上驗證輸入。這個問題與PCI有什麼關係? – Sam
客戶端驗證通常只是給用戶提供快速反饋,並且所有的驗證都必須在服務器上重做,因爲服務器必須保持其數據庫不會收到不良內容,並保護自己免受惡意輸入。 –