Like SystemiConnectFri 15 Oct 2021, 04:50
Auto Save MessagesLGforumFri 26 Feb 2021, 13:31
New tutorial questionTheCrowMon 15 Feb 2021, 08:12
Support iOS Emojis (and other platforms)LGforumSun 14 Feb 2021, 01:25
LGforum (2806)
Script didn't alert Vote_lcapScript didn't alert Voting_barScript didn't alert Vote_rcap 
Mr.Easybb (1587)
Script didn't alert Vote_lcapScript didn't alert Voting_barScript didn't alert Vote_rcap 
Bloodbath (745)
Script didn't alert Vote_lcapScript didn't alert Voting_barScript didn't alert Vote_rcap 
Rukiafan (533)
Script didn't alert Vote_lcapScript didn't alert Voting_barScript didn't alert Vote_rcap 
Dom (513)
Script didn't alert Vote_lcapScript didn't alert Voting_barScript didn't alert Vote_rcap 
puppycheese (446)
Script didn't alert Vote_lcapScript didn't alert Voting_barScript didn't alert Vote_rcap 
pedro (330)
Script didn't alert Vote_lcapScript didn't alert Voting_barScript didn't alert Vote_rcap 
Neymar (301)
Script didn't alert Vote_lcapScript didn't alert Voting_barScript didn't alert Vote_rcap 
Hitsu (281)
Script didn't alert Vote_lcapScript didn't alert Voting_barScript didn't alert Vote_rcap 
Flora (275)
Script didn't alert Vote_lcapScript didn't alert Voting_barScript didn't alert Vote_rcap 


Script didn't alert

avatarNewbie JS
Status : No status yet...

Posts : 30
Join date : 2015-01-23
Age : 35
Location : England
Sun 10 May 2015, 06:38
I have this little piece of code

Code:
<head>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.10.2.js">
<script>
function keyup(evt) {
 alert(evt.keyCode);
}

if($(input).val() > 1) {
 alert("Type ONLY ONE character.");
}
</script>
</head>
<body>
<input type="text" onKeyUp="keyup(evt)">
</body>

But somehow it doesn't alert the [ic]keyCode[/ic]. :/
LGforumLGforum
Status : Working to restore AWC!

Posts : 2806
Join date : 2011-10-05
Age : 30
Location : UK
Sun 10 May 2015, 10:02
The correct attribute name is onkeyup. No capitals.
Also you'll get an error onload anyway which says something along the lines of 'input is not defined' because your trying to use a variable that you haven't defined.
Lastly your check for the length of the value needs to be inside the key up function too, otherwise it will never be relevant.
BloodbathBloodbath
Status : No status yet...

Posts : 745
Join date : 2013-05-31
Age : 28
Sun 10 May 2015, 10:10
LGforum wrote:[quotelink="http://www.avacweb.com/t2429-script-didn-t-alert#23191"]The correct attribute name is onkeyup. No capitals.
Also you'll get an error onload anyway which says something along the lines of 'input is not defined' because your trying to use a variable that you haven't defined.
Lastly your check for the length of the value needs to be inside the key up function too, otherwise it will never be relevant.

But HTML is case-insensitive, isn't it? That's not the issue, it's the undefined variable that is.
LGforumLGforum
Status : Working to restore AWC!

Posts : 2806
Join date : 2011-10-05
Age : 30
Location : UK
Mon 11 May 2015, 18:44
I believe it is yeah, however I pointed it out as a possible issue because despite the JS error, that wouldn't effect the functioning of the onkeyup, since the function has already been defined before the JS undefined error, and the attribute is within the HTML - so even with that error in the JavaScript, the event should still work.
Sponsored content