Form Validation

0 Nupur Singh · May 5, 2015
Hi I am unable to make the form validation work.

Here is my code-
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html>
<head>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html>
<head>
<script type="text/javascript">
   function validator(){
      if (document.Nupurform.thebox.checked)
     alert("Yes it is chckd!");
 else
     alert("No it is not chckd!");
   }
</script>
</head>
<body>

<form name ="Nupurform">
   <input type="checkbox" name="thebox" />
   <input type="button" value="Press me!" onClick-"validator()" />

</form>

</body>
</html>

Please suggest where I need to make changes

Post a Reply

Replies

Oldest  Newest  Rating
0 Skylar Cross · May 6, 2015
on your onClick it needs to be a = not a -


and on your if statement look up document.forms['name of form']['name of input'].

and place your code inside this

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
</head>
<body>
    
</body>
</html>
0 Sampan Verma · May 6, 2015
This mistake is so funny.
0 Ojas More · May 9, 2015
http://cosmothegod.blogspot.in/2015/03/html-signup-form-example.html
  • 1

Javascript

107,257 followers
About

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

Links
Moderators