Code isn't Working???

Discussion in 'JavaScript' started by 911511, Feb 22, 2012.

  1. #1
    code isn't working.
    <script type="text/javascript">
    <!-- function validate(){
    if ((document.example2.naming.value=="")|| (document.example2.feed.value=="")){
    .alert ("You must fill in all of the required .fields!")
    .return false.}
    else return true }
    //--> </script>
    <form name="example2"onsubmit="return validate()"> <input type="text" size="20" name="naming">
    <strong>Feedback please: (*required)</strong>
    <textarea name="feed" rows="3" cols="25"></textarea>
    <strong>Your home address (*NOT required)</strong>
    <input type="text" size="35" name="address">
    <input type="submit" name="B1" value="Submit">
    </form>
     
    911511, Feb 22, 2012 IP
  2. ker

    ker Peon

    Messages:
    97
    Likes Received:
    0
    Best Answers:
    1
    Trophy Points:
    0
    #2
    Hello!
    That should work...
    Make sure that you close all html tags i.e. <input type="text" size="20" name="naming" />.
    Also use semi colon in JavaScript.
    And use [ HTML ] when posting to forum. :)
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
    
    <head>
    	<title>untitled</title>
    	<meta http-equiv="content-type" content="text/html;charset=utf-8" />
    	<script type="text/javascript"> 
    		function validate()
    		{
    			if ((document.example2.naming.value=="") || (document.example2.feed.value==""))
    			{ 
    				alert ("You must fill in all of the required fields!");
    				return false;
    			} 
    			return true;
    		}
    	</script>
    </head>
    	<body>
    		<form name="example2"onsubmit="return validate()">
    			<input type="text" size="20" name="naming" />
    			<strong>Feedback please: (*required)</strong> 
    			<textarea name="feed" rows="3" cols="25"></textarea> 
    			<strong>Your address (*NOT required)</strong>
    			<input type="text" size="35" name="address" />
    			<input type="submit" name="B1" value="Submit" /> 
    		</form>
    	</body>
    </html>
    
    HTML:
     
    ker, Feb 22, 2012 IP
  3. 911511

    911511 Peon

    Messages:
    45
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Yap its work
    Thanks :)
     
    911511, Feb 23, 2012 IP