即時通訊設法創建一個html + JS表單..我設法讓它工作,因爲我想..但我想增加一個字段到它,我不知道如何做到這一點。 即時通訊不善於js所以需要幫助。JS valide form for a value
即時通訊試圖做的是..當用戶填寫表單..其中一個領域應提交前驗證促銷代碼。
<script type="text/javascript">
function get(y){
return document.getElementById(y).value;
}
function getResponse(){
$.get("process.php", { name: get('name'), email: get('email'), postcode: get('postcode'), phone: get('phone'), postcode: get('fbcode') },
function(data){
if(data.status === false || data.status === 'false'){
return errorMsg(data.message);
}else{
errorMsg(data.message);
setTimeout(" offerDownloadAndClose()", 4000);
}
}, "json");
}
function errorMsg(msg){
$('#status').html(msg);
$('#status').slideDown('slow');
setTimeout("doHide('#status')", 3000);
}
function doHide(t){
$(t).slideUp('slow');
}
function offerDownloadAndClose(){
doHide('#fancybox-wrap, #fancybox-overlay');
window.location = 'process.php?file=true';
}
function validnum(evt){
var charCode;
charCode = (evt.which) ? evt.which : event.keyCode;
if ((charCode >= 48 && charCode <= 57) || charCode == 46 || charCode == 127 || charCode == 8)
{
return true;
}
else{
return false;
}
}
</script>
我需要添加更多的領域與Facebook促銷代碼..所以說,我們的代碼是FaceCode1,當用戶在表單填寫..它驗證字段與此值..如果代碼是FaceCode1它會處理,否則會給出錯誤來填寫它。
所以它應該像
function validcode{
if value=FaceCode1
{return true;
}
else{
return false;
}
}
,但我不知道如何創造價值,以特定的代碼來檢查.. 請,如果有人可以幫助我在這個..真的很感激它。 謝謝。
你能提供的HTML和CSS嗎?最好在[jsfiddle](http://jsfiddle.net) – 2013-02-14 17:23:18