Avatar of sassy4sure
sassy4sure
 asked on

Passing Form Variables with Javascript

Hi I would like to know why this piece of code does not show an empty string alert like it should. I think I am not passing the text field variables correctly or something along those lines.
Help would be greatly appreciated
//Form PHP
 
<SCRIPT language="JavaScript">
 
<!--
 
 function checkForm() 
 {
      var err = "";
  
    err += checkLogin();//check for empty string
  
    if (err != "")
  	{
         alert(err);
       	 return false;
	 }
 
return true;
}
-->
 
</SCRIPT>
 
<Script language="javascript" src="validator.js"></Script>
</head>
/*
omit stuff
*/
 
<form id="Login" action="wel.php" name="frmLog"
onsubmit="return checkForm();">
 
/*
omit stuff
*/
<td><input type="text" name="logID" id="logID" class="form250"></td>
 
******************
 
//validator.js
// JavaScript Document
function checkLogin ()
{  
    var strng=document.frmLog.logId.value;//get log in txtfield
    var error=" ";
   
    if (strng == " ") 
    {
        error = "Your Login ID must not be empty.\n";
    }
     return error;
       
}

Open in new window

JavaScriptWeb Applications

Avatar of undefined
Last Comment
Ionut A. Tudor

8/22/2022 - Mon
SOLUTION
Albert Van Halen

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
ASKER CERTIFIED SOLUTION
Ionut A. Tudor

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
I started with Experts Exchange in 2004 and it's been a mainstay of my professional computing life since. It helped me launch a career as a programmer / Oracle data analyst
William Peck