Javascript 文档中出现空错误。getElementByid(“dthchannel”和“x2B;”[i]为空) 函数验证() { var标志=0; 变量spchar=/^[a-zA-Z0-9]*$/; var num=/^[0-9]*$/; var custid=document.getElementById('CUSTOMERID')。值; var phoNo=document.getElementById('PHONENO')。值; var emailId=document.getElementById('emailId').value; var channel=document.getElementById('CHANNELDTL')。值; 如果(通道==“”) { 警报(“您尚未选择任何频道”); flag=1; 返回false; } 如果(custid==“”| | custid==null) { 警报(“请输入客户ID”); document.getElementById('CUSTOMERID').focus(); flag=1; 返回false; } if(custid.search(num)=-1) { 警报(“客户应为数字”); document.getElementById('CUSTOMERID').focus(); flag=1; 返回false; } if(phoNo==“”| | phoNo==null) { 警报(“请输入电话”); document.getElementById('PHONENO').focus(); flag=1; 返回false; } 如果(语音搜索(num)=-1) { 警报(“电话应为数字”); document.getElementById('PHONENO').focus(); flag=1; 返回false; } 如果(emailId==“”| | emailId==null) { 提醒(“请输入电子邮件”); document.getElementById('EMAILID').focus(); flag=1; 返回false; } 如果(电子邮件ID) { if(isValidEmail(document.getElementById('EMAILID').value)==false) { 警报(“请输入有效电子邮件”); document.getElementById('EMAILID').focus(); flag=1; 返回false; } } 如果(标志==0) { var emailid=Base64.tripleEncoding(document.getElementById('emailid').value); document.getElementById('E_EMAIL')。value=emailid; document.getElementById('EMAILID')。value=“”; var mobileno=Base64.tripleEncoding(document.getElementById('PHONENO').value); document.getElementById('E_PHONE')。value=mobileno; document.getElementById('PHONENO')。value=“”; var customerid=Base64.tripleEncoding(document.getElementById('customerid').value); document.getElementById('E_CUSTID')。value=customerid; document.getElementById('CUSTOMERID')。value=“”; document.topupsform.action=“../dth/leads/channelMail/channelMailUtil.jsp”; document.topupsform.submit(); 警报(“感谢您选择点菜服务。\n我们将在24小时内处理。\n您将很快收到您的邮件id确认”); } } 功能isValidEmail(电子邮件) { 变量reg=/^([A-Za-z0-9\-\.])+\@([A-Za-z0-9\-\.])+\.([A-Za-z]{2,4})$/; var地址=trim(电子邮件); 如果(注册测试(地址)=错误) { 返回false; } 其他的 返回true; } 功能微调(str) { str=这个!=窗口?这个:str; 返回str.replace(/^\s+/g')。replace(/\s+/$/g'); } 函数sendMail() { caltotal(); 验证(); } //---------------------------------- var计数器=0; 函数resetcheckboxValue(){ //var totalinputs=document.topupsform.getElementsByTagName(“输入”); var totalinputs=document.getElementsByName(“dthchannel”); var TotalEnght=totalinputs.length; 计数器=0; 对于(变量i=0;i
您需要修改如下所示的任何行:Javascript 文档中出现空错误。getElementByid(“dthchannel”和“x2B;”[i]为空) 函数验证() { var标志=0; 变量spchar=/^[a-zA-Z0-9]*$/; var num=/^[0-9]*$/; var custid=document.getElementById('CUSTOMERID')。值; var phoNo=document.getElementById('PHONENO')。值; var emailId=document.getElementById('emailId').value; var channel=document.getElementById('CHANNELDTL')。值; 如果(通道==“”) { 警报(“您尚未选择任何频道”); flag=1; 返回false; } 如果(custid==“”| | custid==null) { 警报(“请输入客户ID”); document.getElementById('CUSTOMERID').focus(); flag=1; 返回false; } if(custid.search(num)=-1) { 警报(“客户应为数字”); document.getElementById('CUSTOMERID').focus(); flag=1; 返回false; } if(phoNo==“”| | phoNo==null) { 警报(“请输入电话”); document.getElementById('PHONENO').focus(); flag=1; 返回false; } 如果(语音搜索(num)=-1) { 警报(“电话应为数字”); document.getElementById('PHONENO').focus(); flag=1; 返回false; } 如果(emailId==“”| | emailId==null) { 提醒(“请输入电子邮件”); document.getElementById('EMAILID').focus(); flag=1; 返回false; } 如果(电子邮件ID) { if(isValidEmail(document.getElementById('EMAILID').value)==false) { 警报(“请输入有效电子邮件”); document.getElementById('EMAILID').focus(); flag=1; 返回false; } } 如果(标志==0) { var emailid=Base64.tripleEncoding(document.getElementById('emailid').value); document.getElementById('E_EMAIL')。value=emailid; document.getElementById('EMAILID')。value=“”; var mobileno=Base64.tripleEncoding(document.getElementById('PHONENO').value); document.getElementById('E_PHONE')。value=mobileno; document.getElementById('PHONENO')。value=“”; var customerid=Base64.tripleEncoding(document.getElementById('customerid').value); document.getElementById('E_CUSTID')。value=customerid; document.getElementById('CUSTOMERID')。value=“”; document.topupsform.action=“../dth/leads/channelMail/channelMailUtil.jsp”; document.topupsform.submit(); 警报(“感谢您选择点菜服务。\n我们将在24小时内处理。\n您将很快收到您的邮件id确认”); } } 功能isValidEmail(电子邮件) { 变量reg=/^([A-Za-z0-9\-\.])+\@([A-Za-z0-9\-\.])+\.([A-Za-z]{2,4})$/; var地址=trim(电子邮件); 如果(注册测试(地址)=错误) { 返回false; } 其他的 返回true; } 功能微调(str) { str=这个!=窗口?这个:str; 返回str.replace(/^\s+/g')。replace(/\s+/$/g'); } 函数sendMail() { caltotal(); 验证(); } //---------------------------------- var计数器=0; 函数resetcheckboxValue(){ //var totalinputs=document.topupsform.getElementsByTagName(“输入”); var totalinputs=document.getElementsByName(“dthchannel”); var TotalEnght=totalinputs.length; 计数器=0; 对于(变量i=0;i,javascript,Javascript,您需要修改如下所示的任何行: function validate() { var flag=0; var spchar=/^[a-zA-Z0-9 ]*$/; var num=/^[0-9]*$/; var custid = document.getElementById('CUSTOMERID').value; var phoNo = document.getElementById('PHONENO').value; var emailI
function validate()
{
var flag=0;
var spchar=/^[a-zA-Z0-9 ]*$/;
var num=/^[0-9]*$/;
var custid = document.getElementById('CUSTOMERID').value;
var phoNo = document.getElementById('PHONENO').value;
var emailId = document.getElementById('EMAILID').value;
var channel = document.getElementById('CHANNELDTL').value;
if(channel=="")
{
alert("You have not selected any channel");
flag=1;
return false;
}
if(custid=="" || custid==null )
{
alert("Please enter Customer ID");
document.getElementById('CUSTOMERID').focus();
flag=1;
return false;
}
if (custid.search(num)==-1)
{
alert("Customer should be Numeric");
document.getElementById('CUSTOMERID').focus();
flag=1;
return false;
}
if(phoNo=="" || phoNo==null )
{
alert("Please enter Phone");
document.getElementById('PHONENO').focus();
flag=1;
return false;
}
if (phoNo.search(num)==-1)
{
alert("Phone should be Numeric");
document.getElementById('PHONENO').focus();
flag=1;
return false;
}
if(emailId=="" || emailId==null )
{
alert("Please enter Email");
document.getElementById('EMAILID').focus();
flag=1;
return false;
}
if (emailId)
{
if(isValidEmail(document.getElementById('EMAILID').value) == false)
{
alert("Please enter valid Email");
document.getElementById('EMAILID').focus();
flag=1;
return false;
}
}
if(flag==0)
{
var emailid=Base64.tripleEncoding(document.getElementById('EMAILID').value);
document.getElementById('E_EMAIL').value=emailid;
document.getElementById('EMAILID').value="";
var mobileno=Base64.tripleEncoding(document.getElementById('PHONENO').value);
document.getElementById('E_PHONE').value=mobileno;
document.getElementById('PHONENO').value="";
var customerid=Base64.tripleEncoding(document.getElementById('CUSTOMERID').value);
document.getElementById('E_CUSTID').value=customerid;
document.getElementById('CUSTOMERID').value="";
document.topupsform.action="../dth/leads/channelMail/channelMailUtil.jsp";
document.topupsform.submit();
alert("Thank you for choosing A-La-Carte services.\nWe will process it within 24 hours.\nYou will soon receive confirmation on your mail id.");
}
}
function isValidEmail(Email)
{
var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
var address = trim(Email);
if(reg.test(address) == false)
{
return false;
}
else
return true;
}
function trim(str)
{
str = this != window? this : str;
return str.replace(/^\s+/g, '').replace(/\s+$/g, '');
}
function sendMail()
{
caltotal();
validate();
}
//----------------------------------
var counter = 0;
function resetcheckboxValue(){
//var totalinputs = document.topupsform.getElementsByTagName("input");
var totalinputs =document.getElementsByName("dthchannel");
var totallenght = totalinputs.length;
counter = 0;
for(var i = 0; i < totallenght; i++) {
// reset all checkboxes
document.getElementsByName("dthchannel")[i].checked = false;
document.getElementById("totalamount").value = "0";
document.getElementById("youpay").value = "0";
}
}
function caltotal()
{
var plansObj = document.getElementsByName("dthchannel");
var plansLength = plansObj.length;
counter = 0;
var finalNameValue = "";
for(var i = 1; i <= plansObj.length+1; i++) {
if ( document.getElementById(("dthchannel")+ [i]).checked)
{
var gvalue = parseInt(document.getElementById(("dthchannel")+[i]).value);
var gNameValue= document.getElementById("CHANNELNAME"+i).value+"~"+gvalue+"#";
finalNameValue+= gNameValue;
counter+= gvalue;
}
showresult();
}
var finallist = finalNameValue.substring(0,finalNameValue.length-1);
//alert("finallist" +finallist);
document.getElementById("CHANNELDTL").value= finallist;
}
function showresult(){
if(counter <= 150 && counter > 0){
document.getElementById("youpay").value = "150";
document.getElementById("totalamount").value = counter;
}
else
{
document.getElementById("youpay").value = counter;
document.getElementById("totalamount").value = counter;
}
}
window.onload = resetcheckboxValue;
你不想做
document.getElementById((“dthchannel”)+[i])
,因为我以前从未见过,而且我认为它不起作用。这是因为你可能没有替换它的所有实例。继续寻找你有getElementById((“dthchannel”)+[i]的地方
并替换它们。这种打字错误是纯粹偶然的([1,2,3])。toString()在我测试过的所有浏览器中生成1,2,3
).所以这个错误有什么解决方案吗?我已经在所有地方更改了它,但仍然没有得到结果,请帮我一个忙,让我知道它需要在代码文件中替换的位置。看起来它们都在caltotal()函数中,但我确信无论返回什么错误,都应该告诉您它在哪一行。
var gvalue = parseInt(document.getElementById("dthchannel" + i).value);