下面的代码是我写的一些JavaScript。
标记的行显示错误:
<script language="javascript" type="text/javascript">
function ValidateOffpoint( )
{
var txt= document.getElementById('txtOffpoint')
if (txt.value.length<=3)
{
txt.focus()
return;
}
if (txt.value=="No Record Found" || txt.value=="")
{
txt.value=""
txt.focus()
return;
}
}
function ConvertToUpperOffPoint()
{
var txtOffpoint = document.getElementById("txtOffpoint");
txtOffpoint.value = txtOffpoint.value.toUpperCase();
}
function CheckTxtBox()
{
strTextBoxVal = document.getElementById('txtOffpoint');
// ############################ Error in next line ############################
strOrigin = Session("LocCode")
if(strTextBoxVal.value.length > 0 )
{
if(strTextBoxVal.value.length < 3 )
{
lblErrMsg.innerText = "Flight Offpoint should not be less than 3 characters";
strTextBoxVal.focus();
return false;
}
}
if (strTextBoxVal.value.substring(0,3) == strOrigin)
{
lblErrMsg.innerText = "Origin and Flight OffPoint cannot be the same.";
strTextBoxVal.focus();
return false;
}
if(strTextBoxVal.value=="" )
{
if (document.getElementById("hdnHandled").value=="true")
{
lblErrMsg.innerText = "Flight Offpoint is required field for Handled Airline.";
strTextBoxVal.focus();
return false;
}
}
lblErrMsg.innerText = "";
return validateFlightNo();
}
</script>
请帮帮我。 :-(
答案 0 :(得分:2)
您正在将服务器端代码与客户端代码混合使用。 将功能更改为:
function CheckTxtBox()
{
strTextBoxVal = document.getElementById('txtOffpoint');
strOrigin = "<%=Session("LocCode")%>";
if(strTextBoxVal.value.length > 0 )
{
if(strTextBoxVal.value.length < 3 )
{
lblErrMsg.innerText = "Flight Offpoint should not be less than 3 characters";
strTextBoxVal.focus();
return false;
}
}
答案 1 :(得分:1)
我的猜测是构造函数Session存在并且您打算使用:
strOrigin = new Session("LocCode")