0
我需要一些代碼,後一種形式,我試圖通過與預先定義後的程序變量如何檢查變量的內容提交
<form id="post_code">
<input name="textfield" type="text" id="postcode" size="8" maxlength="8" />
<input type="image" id="submit_postcode" src="images/B_go.png" alt="Submit Postcode" width="59" height="24" border="0" />
</form>
var districtPostcodes = ['B1', 'B2', 'B3','B4'];
$("#submit_postcode").submit(function(){
var userPostcode = $("#postcode").val().replace(/[^a-zA-Z0-9]/gi,'').toUpperCase();
$.grep(districtPostcodes , function(val, i){
if(userPostcode.indexOf(val) === 0){
alert("Users postcode is part of district: "+val);
return true;
}else{
return false;
});
});
用戶檢查給定的代碼後
感謝您的幫助。
究竟是什麼問題? – 2009-08-03 22:14:50