The code below is some JavaScript which I have written.
It is showing an error on the marked line:
<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 &g开发者_Go百科t; 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>
Please, help me out. :-(
You are mixing server side code with client side code. Change the function to:
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;
}
}
my Guess is that the constructor Session exists and you meant to use:
strOrigin = new Session("LocCode")
精彩评论