Beginner JavaScript Tutorial - 40 - Simple Form Validation - help needed!:)

+1 Paulina Surazynska · January 2, 2015
as in the topic...


where's the mistake?
I can't find it, maybe You will ?;)
thank tyou for help!:)



<!DOCTYPE html>
<html>
<head>
<script type="text/javascript">
 function sprawdza(){
if(document.formularz.thebox.checked)
alert("udalo sie!");
else 
alert("niep!");
 }
</script>
</head>
<body>
<form name="formularz">
<input type="checkbox" name="thebox" />
<input type="button" value="nacisnij" onClick="sprawdza" />
</form>

</body>
</html>

Post a Reply

Replies

Oldest  Newest  Rating
+1 karam karamovic · January 2, 2015
Hi;

i think that's the mistake

<input type="button" value="nacisnij" onClick="sprawdza()" />
-1 Paulina Surazynska · January 2, 2015
:)
thank you guys!:)
0 Sochima Biereagu · January 10, 2015
//use "onChange" instead of "onClick"

<!DOCTYPE html>
<html>
<head>
<script type="text/javascript">
function sprawdza(element){
if(element.checked == true) alert("udalo sie!");
else alert("niep!");
}
</script>
</head>
<body>
<form name="formularz">
<input type="checkbox" name="thebox" />
<input type="button" value="nacisnij" onChange="sprawdza(this);" />
</form>
</body>
</html>
  • 1

Javascript

107,126 followers
About

A scripting language that is added to standard HTML to create interactive effects, apps, games for the browser.

Links
Moderators