2013-07-30 28 views
0

我正在嘗試爲Salesforce創建一個Web到Case的表單,並且需要製作自定義案例字段。我將代碼添加到我的html頭部,並且它不工作。表單也不會提交。Salesforce web到案例所需字段

<html> 
<head> 
<script language="JavaScript" type="text/javascript"> 

function checkform (form) 
{ 
var name = document.getElementById('00NC0000005KA85').value; 
if (form.name.value == "") { 
alert("Please enter your full name.");form.name.focus(); 
return false ; 
} 
return true ; 
} 

</script> 
</head> 
<body> 

<form action="https://www.salesforce.com/servlet/servlet.WebToCase?encoding=UTF-8" method="POST" onsubmit="return checkform(this);"> 

回答

0

我不完全明白你的問題,但是,閱讀你已經得到了表單字段的值,當你做了DOM查找後,才使得if語句錯了,我認爲這可能是正確的代碼:

function checkform (form) { 
    var name = document.getElementById('00NC0000005KA85'); 
    if (name.value == "") { 
     alert("Please enter your full name."); 
     name.focus(); 
     return false ; 
    } 
    return true; 
} 

此外,你確定表單字段將始終有ID「00NC0000005KA85」?這看起來會生成,如果DOM節點丟失,表單將不再提交。