Switch to full style
HTML,DHTML,Javascript,XML,CSS
Post a reply

cotact us html and javascript form

Mon Dec 01, 2008 12:15 am

Here an html and javascript form , you can put it in your site to allow users to send mails to using this form and they can decide their topic and part ,you should action the form to any dynamic script like php to send mail .
html code
 <script language="javascript" type="text/javascript">
    function validateForm()
    {
            document.getElementById('errorDiv').innerHTML="";        
            var errorDiv = document.getElementById('errorDiv');
            var email = document.getElementById('email').value;
            var name = document.getElementById('name').value;
            var comment = document.getElementById('comment').value;
            var feedbackTypeindex = document.getElementById('FeedbackType').selectedIndex;                        
            var subject = document.getElementById('subject').value;            
            apos=email .indexOf("@");
            dotpos=email .lastIndexOf(".");
            var errorDiv = document.getElementById('errorDiv');

        if(feedbackTypeindex == 0)
        {
            //alert("Please select feedback type");
            //document.getElementById('errorDiv').innerHTML="<li><font color='red'>Please select feedback type</font></li>";
            errorDiv.innerHTML = "<li><font color='red'>Please select feedback type</font></li>";
            return false ;
        }
        
        if(name== null || name=="")
        {
            //alert("Please enter your name");
            errorDiv.innerHTML = "<li><font color='red'>Please enter your name</font></li>";
            return false;
        }
        
        if(email == null || email =="")
        {
            //alert("Please enter email address");
            errorDiv.innerHTML = "<li><font color='red'>Please enter email address</font></li>";
            return false;
        }
        else if (apos<1||dotpos-apos<2) 
        {
            //alert("Please enter valid email address, ie.:[email protected]");
            errorDiv.innerHTML = "<li><font color='red'>Please enter valid email address, ie.:[email protected]</font></li>";
            return false;
        }
        
        
        
        
        if(subject == null || subject=="")
        {
            //alert("Please enter the subject");
            errorDiv.innerHTML = "<li><font color='red'>Please enter the subject</font></li>";
            return false;
        }
        
        if(comment== null || comment=="")
        {
            //alert("Please enter the message");
            errorDiv.innerHTML = "<li><font color='red'>Please enter the message</font></li>";
            return false;
        }        
    }
    </script>
 
   <div class="content" >
 
<div>
<table border="0">
<form name="contacts" action="<?=$HOST?>Services/mail.php" method="post" onSubmit="return validateForm();">
<tr><td colspan="2">
feedback type</td><td><select name="FeedbackType" id="FeedbackType">
<option value="0">- select -</option> 
<option value="Sponsership">sponsorship</option>

<option value="ads">Advertise</option> 
<option value="others">Others</option> 
</select></td></tr>
<tr><td colspan="2">
name</td><td><input type="text" name="name" id="name" value="" maxlength="30" /></td></tr>
<tr><td colspan="2">
email</td><td><input type="text" name="email" id="email" value="" maxlength="30" />&nbsp;example: [email protected]</td></tr>
<tr><td colspan="2">
subject</td><td><input type="text" name="subject" id="subject" value="" maxlength="30" /></td></tr>
<tr><td colspan="2">
comments</td><td><textarea name="comment" id="comment" rows="5" cols="30"></textarea></td></tr>
<tr><td colspan="2"></td><td><input type="submit" value="send" style="width:100px"  /></td></tr>
</form>
<tr><div id="errorDiv" name="errorDiv" style="margin-left:15px;" ></div> </tr>
</table>
</div>
</div>



Attachments
form.GIF
form screenshot ,
form.GIF (5.33 KiB) Viewed 7450 times

Post a reply
  Related Posts  to : cotact us html and javascript form
 HTML registration form example     -  
 HTML Form i made     -  
 PHP HTML form with to file upload     -  
 getting gst, pst total to diplay in my javascript form     -  
 Javascript Form Calculation Error :banghead:     -  
 form-Radio-buttons-checkBoxs-actions-HTML-Tags     -  
 I'm having a problem creating a Javascript form. Whats wrong     -  
 How to use HTML with JavaScript     -  
 Hide HTML Div using JavaScript     -  
 php login form (sign-in form)     -  

Topic Tags

HTML Form, JavaScript Validation