Jump to content



Photo

logon function


  • Please log in to reply
17 replies to this topic

#16 +Seahorsepip

Seahorsepip

    http://seapip.com

  • Tech Issues Solved: 15
  • Joined: 23-January 11
  • Location: Vlissingen, Netherlands
  • OS: Windows 8 Pro
  • Phone: Sony Xperia Z White

Posted 12 February 2014 - 16:26

Yes, I believe everybody here is aware of that.

I know most of us are aware of it but people starting with programming like OP might not know that ;)




#17 OP damindor

damindor

    Neowinian

  • Joined: 30-December 11

Posted 13 February 2014 - 06:56

 

As of html 5 a script declaration is unnecessary. For some reason, the op is using xhtml which should use it for standards but should still work. 

 

Whats wrong here:

Case sensitivity: you name your function logon, and then call the function Logon that doesnt exist.

Function outside script tags. Why are you just calling "logon" in the body? You need to wrap all javascript in script tags (apart from some cases like forms).

<!DOCTYPE html>
<html>
<head>
<title>Untitled Document</title>
<script>
function logon() {
	var userid;
 	var password;
 	var valid
 	
 	userid=prompt('enter userid','');
 	password=prompt('enter password','');
 	valid=validatelogon(userid,password);
 
 	if(valid==true) {
 		alert('valid logon');
 	} else {
 		alert('invalid logon');
 	}
 
function validatelogon(id,pwd) {
 	var Returnvalue;
 	if(id=='peter' && pwd =='tree') {
 		Returnvalue=true;
 	} else {
 		Returnvalue=false;
 	}
 return Returnvalue;
}

}
</script>
</head>
 
<body>
<script>
logon();
</script>
 
</body>
</html>

 

I copied and paste it and it works fine I am gonna compare text  I am using dreamweaver because the colors tell you went you spell somethign wrong or forget a tag if document.write is not pink you know its spelled wrong is their a program thats shows missing semi colons and so on

 



#18 the better twin

the better twin

    Neowinian Senior

  • Tech Issues Solved: 2
  • Joined: 26-January 10
  • OS: Win 8
  • Phone: Nokia Lumia

Posted 13 February 2014 - 09:17

I copied and paste it and it works fine I am gonna compare text  I am using dreamweaver because the colors tell you went you spell somethign wrong or forget a tag if document.write is not pink you know its spelled wrong is their a program thats shows missing semi colons and so on

I don't think so, many editors often automatically insert them for you tho. Technically JavaScript doesnt need you to write the semicolons because of Automatic semicolon insertion, however, I advise you should learn where to use them. http://inimino.org/~...ipt_semicolons 





Click here to login or here to register to remove this ad, it's free!