Showing alert box after ' submit'

Discussion in 'HTML & Website Design' started by rrn, Apr 14, 2009.

  1. #1
    hi..

    in my website , i have a form for sending emails...
    everything is working fine, except one..

    in the form there is two fields, one for entering name and other for email id..

    my problem is tat , even after filling both the text fields and then click ' submit', it is showing alert to enter name and email...

    pls help me to solve it..

    below shown is the code i've used..

    <html>
    <head>
    <script type="text/javascript" language="JavaScript">
    
    function validate() {
    var errormessage = new String();
    
    if(checkname(document.form.name))
    	{ errormessage += "\n\nPlease enter name."; }
    if(checkemail(document.form.email))
    	{ errormessage += "\n\nPlease enter email."; }
    if(errormessage.length > 2) {
    	alert('NOTE:' + errormessage);
    	return false;
    	}
    return true;
    }
    
    function checkname(ss) {
    for(var i = 0; i < ss.length; i++) {
    	if(ss[i].checked) { return false; }
    	}
    return true;
    }
    
    function checkemail(ss) {
    if(ss.checked) { return false; }
    return true;
    }
    
    </script>
    
    
    
    
    
    
    </head>
    <body>
    
    
                       		    
    
       <form name="form" action="index.{EXT}" method="POST"  enctype="multipart/form-data"  onsubmit="return validate();">
    	<table border="1" width="100%" bordercolor="#D0D0D0" bgcolor="">
    
        <tr>
    	<td colspan="2" class="f-bold fs-11 bg-1 fc-FFF" align="center">Email Alerts</td>
    	</tr>
    	<tr>
    	<td class="bg-EEE f-bold" width="100">Name</td>
    	<td class="bg-F7F"><input type="text" id="name" name="name"  value="{rates.NAME}"  class="box-60" /></td>
    	</tr>
    	<tr>
    	<td class="bg-EEE f-bold" width="100">Email</td>
    	<td class="bg-F7F"><input type="text" id="email" name="email"  value="{rates.EMAIL}"  class="box-60" /></td>
    	</tr>
    	<tr>
         <td colspan="2" align="center"><input type="submit" name="submit" value=" Submit " class="button f-bold pb-3" />
    <input type="reset" name="reset" value=" Reset " class="button f-bold pb-3" />
        </td>
        </tr>
    	</table>
    	</form>
                       
    <br />
    	</td>
    			</tr>
    		</table>
    		</div>
    		</body>
      </html>
    
    HTML:
    pls help me to find the mistake in the code

    thanks..
     
    rrn, Apr 14, 2009 IP
  2. rrn

    rrn Peon

    Messages:
    54
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    somebody please give me a solution to this.......
    please help me.......

    i will be very grateful...
    Thank u......
     
    rrn, Apr 14, 2009 IP