www.webdeveloper.com
Page 1 of 3 123 LastLast
Results 1 to 15 of 36

Thread: Validating textarea

  1. #1
    Join Date
    Nov 2006
    Posts
    229

    Validating textarea

    Can someone help me figure out why the form validating is working good up until I get to the textarea(message) field?....after typing characters into the textarea(message) field I still keep getting a prompt that its still empty. Below is javascript code and the area where it hangs up is in BOLD:

    Code:
    function echeck(YourName, str, message) 
    	  {
    	  var emailID=document.form1.EmailHome.value
    	    
    	  if ((YourName==null)||(YourName=="")){
    		alert("Please Enter your Your Name");
    		document.form1.YourName.focus()
    		return false
    	  }
    	  
    	    var at="@"
    		var dot="."
    		var lat=str.indexOf(at)
    		var lstr=str.length
    		var ldot=str.indexOf(dot)
    		if (str.indexOf(at)==-1){
    		   alert("Invalid E-mail ID")
    		   document.form1.EmailHome.focus()
    		   return false
    		}
    
    		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
    		   alert("Invalid E-mail ID")
    		   document.form1.EmailHome.focus()
    		   return false
    		}
    
    		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
    		    alert("Invalid E-mail ID")
    		    document.form1.EmailHome.focus()
    		    return false
    		}
    
    		 if (str.indexOf(at,(lat+1))!=-1){
    		    alert("Invalid E-mail ID")
    		    document.form1.EmailHome.focus()
    		    return false
    		 }
    
    		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
    		    alert("Invalid E-mail ID")
    		    document.form1.EmailHome.focus()
    		    return false
    		 }
    
    		 if (str.indexOf(dot,(lat+2))==-1){
    		    alert("Invalid E-mail ID")
    		    document.form1.EmailHome.focus()
    		    return false
    		 }
    		
    		 if (str.indexOf(" ")!=-1){
    		   alert("Invalid E-mail ID")
    		    document.form1.EmailHome.focus()
    		    return false
    		 }
    	
    		
    	if ((form1.StreetAddress.value==null)||(form1.StreetAddress.value=="")){
    		alert("Please Enter your Street Address");
    		document.form1.StreetAddress.focus()
    		return false
    	  }	
    	  
    	  if ((form1.City.value==null)||(form1.City.value=="")){
    		alert("Please Enter your City");
    		document.form1.City.focus()
    		return false
    	  }	
    	  
    	  if ((form1.Zip.value==null)||(form1.Zip.value=="")){
    		alert("Please Enter your Zip Code");
    		document.form1.Zip.focus()
    		return false
    	  }	
    	
    		  	  
    	  if ((message.value == null)||(message.value=="")){
            alert("Please Enter your Your Message");
            document.form1.message.focus()
            return false
      }
        			 	
    		
    	 else
    	    {
            document.form1.submit()
     		 return true	
            }
        
         }

  2. #2
    Join Date
    Oct 2013
    Posts
    484
    Have you tried:
    Code:
    	  if ((document.form1.message.value == null)||(document.form1.message.value=="")){
            alert("Please Enter your Your Message");
            document.form1.message.focus()
            return false
      }

  3. #3
    Join Date
    Nov 2006
    Posts
    229
    Quote Originally Posted by Kevin2 View Post
    Have you tried:
    Code:
    	  if ((document.form1.message.value == null)||(document.form1.message.value=="")){
            alert("Please Enter your Your Message");
            document.form1.message.focus()
            return false
      }
    Hi Kevin. I tried that and the validation is bypassed and takes me to the next page......so thats not working either.

  4. #4
    Join Date
    Mar 2007
    Location
    localhost
    Posts
    2,346
    Looking at your script, I suspect that you are passing form elements to it and you are using the onsubmit="" in the form to control submission.

    I suggest that you use onsubmit="return echeck(this);" in the form tag, passing the form to the function will mean you don't need to refer to your document.form1 portion of your checks, you just use whatever you use as a variable in the function, eg.

    Code:
    function echeck(o){ // o is the onsubmit="return echeck(this);" line in your form submit
    	event.preventDefault();
    	
    	var emailID		= o.EmailHome.value,
    		yourName	= o.YourName.value,
    		street		= o.StreetAddress.value,
    		city		= o.City.value,
    		zip		= o.Zip.value,
    		msg		= o.message.value;	
    
    	if( yourName.length==0 ){
    		alert("Please Enter your Your Name");
    		o.YourName.focus();
    		return false;
    	}
    	  
    	var parts = emailID.split("@");
    	domain = parts.length>1 && parts[1].indexOf(".")>0 ? true : false;
    	if(!domain){
    		alert("Need Email Address");
    		o.EmailHome.focus();
    	}
    	
    	if ( street.length==0 ){
    		alert("Please Enter your Street Address");
    		o.StreetAddress.focus();
    		return false;
    	  }	
    	  
    	if ( city.length==0 )){
    		alert("Please Enter your City");
    		o.City.focus();
    		return false;
    	  }	
    	  
    	if ( zip.length==0 ){
    		alert("Please Enter your Zip Code");
    		o.Zip.focus();
    		return false;
    	  }	
    	
    		  	  
    	if ( msg.length==0 ){
    		alert("Please Enter your Your Message");
    		o.message.focus();
    		return false;
    	}
        			 	
    	o.submit();
     	return true;
    }
    You need to terminate lines of code properly with a ; and also be aware of using variables that are same as the object you are using and if you declare a variable you want to use it and the testing of length is the same as testing for ==""
    Yes, I know I'm about as subtle as being hit by a bus..(\\.\ Aug08)
    Yep... I say it like I see it, even if it is like a baseball bat in the nutz... (\\.\ Aug08)
    I want to leave this world the same way I came into it, Screaming, Incontinent & No memory!
    I laughed that hard I burst my colostomy bag... (\\.\ May03)
    Life for some is like a car accident... Mine is like a motorway pile up...

    Problems with Vista? :: Getting Cryptic wid it. :: The 'C' word! :: Whois?

  5. #5
    Join Date
    Nov 2006
    Posts
    229
    I tried using the suggested code and its still not working. Its only the textarea field that is giving me a problem.

  6. #6
    Join Date
    Mar 2007
    Location
    localhost
    Posts
    2,346
    You haven't supplied the HTML form that you want validating, that would help because we are really shooting in the dark with only half the problem, for all we know the problem may be in your HTML, missing something, need something changing, we don't know...
    Yes, I know I'm about as subtle as being hit by a bus..(\\.\ Aug08)
    Yep... I say it like I see it, even if it is like a baseball bat in the nutz... (\\.\ Aug08)
    I want to leave this world the same way I came into it, Screaming, Incontinent & No memory!
    I laughed that hard I burst my colostomy bag... (\\.\ May03)
    Life for some is like a car accident... Mine is like a motorway pile up...

    Problems with Vista? :: Getting Cryptic wid it. :: The 'C' word! :: Whois?

  7. #7
    Join Date
    Nov 2006
    Posts
    229

  8. #8
    Join Date
    Mar 2007
    Location
    localhost
    Posts
    2,346
    Not being funny but you could post the webpage code if you want help with it.
    Yes, I know I'm about as subtle as being hit by a bus..(\\.\ Aug08)
    Yep... I say it like I see it, even if it is like a baseball bat in the nutz... (\\.\ Aug08)
    I want to leave this world the same way I came into it, Screaming, Incontinent & No memory!
    I laughed that hard I burst my colostomy bag... (\\.\ May03)
    Life for some is like a car accident... Mine is like a motorway pile up...

    Problems with Vista? :: Getting Cryptic wid it. :: The 'C' word! :: Whois?

  9. #9
    Join Date
    Nov 2006
    Posts
    229
    Quote Originally Posted by \\.\ View Post
    Not being funny but you could post the webpage code if you want help with it.
    Code:
    <script language="JavaScript">
    function setFocus() {
    			document.form1.YourName.focus();
    			}	
        
          function echeck(YourName, str, message) 
    	  {
    	  var emailID=document.form1.EmailHome.value
    	
        
    	  if ((YourName==null)||(YourName=="")){
    		alert("Please Enter your Your Name");
    		document.form1.YourName.focus()
    		return false
    	  }
    	  
    	    var at="@"
    		var dot="."
    		var lat=str.indexOf(at)
    		var lstr=str.length
    		var ldot=str.indexOf(dot)
    		if (str.indexOf(at)==-1){
    		   alert("Invalid E-mail ID")
    		   document.form1.EmailHome.focus()
    		   return false
    		}
    
    		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
    		   alert("Invalid E-mail ID")
    		   document.form1.EmailHome.focus()
    		   return false
    		}
    
    		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
    		    alert("Invalid E-mail ID")
    		    document.form1.EmailHome.focus()
    		    return false
    		}
    
    		 if (str.indexOf(at,(lat+1))!=-1){
    		    alert("Invalid E-mail ID")
    		    document.form1.EmailHome.focus()
    		    return false
    		 }
    
    		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
    		    alert("Invalid E-mail ID")
    		    document.form1.EmailHome.focus()
    		    return false
    		 }
    
    		 if (str.indexOf(dot,(lat+2))==-1){
    		    alert("Invalid E-mail ID")
    		    document.form1.EmailHome.focus()
    		    return false
    		 }
    		
    		 if (str.indexOf(" ")!=-1){
    		   alert("Invalid E-mail ID")
    		    document.form1.EmailHome.focus()
    		    return false
    		 }
    	
    	
    	
    	if ((form1.StreetAddress.value==null)||(form1.StreetAddress.value=="")){
    		alert("Please Enter your Street Address");
    		document.form1.StreetAddress.focus()
    		return false
    	  }	
    	  
    	  if ((form1.City.value==null)||(form1.City.value=="")){
    		alert("Please Enter your City");
    		document.form1.City.focus()
    		return false
    	  }	
    	 
    	 	  
    	  if ((form1.Zip.value==null)||(form1.Zip.value=="")){
    		alert("Please Enter your Zip Code");
    		document.form1.Zip.focus()
    		return false
    	  }	
    	
    		  	  
    	  if (form1.message.length == 0){
            alert("Please Enter your Your Message");
            form1.message.focus();
            return false
      }
        			 	
    		
    	 else
    	    {
            document.form1.submit()
     		 return true	
            }
        
         }
    	 
    
         </script>
    </HEAD>
    <BODY bgcolor="000000">
    
    <form method="post" name="form1" action="">
    
     <table class="FREE_Offer_Form">
     <tr>
      <td>
       &nbsp;
      </td>
     </tr>
    
     <tr align="left">
      <td name="FirstName">
        <font color="ffffff">
             Name
            </font>
             &nbsp;<input name="YourName" size="16">    
           </td>
          </tr>
         
         <tr align="left">
           <td>
            
             <font color="red">**</font>
             <font color="ffffff">Phone
             </font>
             <input name="PhoneNumber" size="15">       
           </td>
           </tr>
          
           <tr align="left">
           <td>
            <font color="ffffff">
             Email 
            </font>
             <input name="EmailHome" size="27">       
           </td>
           </tr>
           
           <tr align="left">
           <td>
            <font color="ffffff">
             Street Address
            </font>
             <input name="StreetAddress" size="27">       
           </td>
           </tr>
           
           <tr align="left">
           <td>
            <font color="ffffff">
             City
            </font>
             <input name="City" size="27">       
           </td>
           </tr>
           
           <tr align="left">
           <td>
            <font color="ffffff">
             Zip
            </font>
             <input name="Zip" size="27">       
           </td>
           </tr>
           
           
           <tr align="left">
           <td>
             <font color="ffffff">County
             </font>
              <select NAME="County" SIZE="1">
                <option value="Bucks">Bucks
    			<option VALUE="Chester">Chester
    			<option VALUE="Delaware">Delaware
    			<option VALUE="Montgomery">Montgomery
    			<option VALUE="Philadelphia">Philadelphia
    	   </td>
           </tr>
           
           <tr align="left">
            <td>
           <table width="200px" align="center">
            <td valign="top">
             <font color="ffffff" size="3">Message</font>
            </td>
            <td> 
              <textarea name="message" cols="25" rows="7">
              </textarea>  
             </td> 
            </table> 
            </td>
           </tr>
           
           <tr align="left">
           <td>
                  
             
            <font color="red">
             ** <i>Optional</i>
             </font>
            </td>
           </tr>
         
     </table>
    <input class="button" type="button" onmouseover"" style="cursor: pointer;" onclick="echeck(document.form1.YourName.value,document.form1.EmailHome.value,document.form1.PhoneNumber.value, document.form1.message.value)" value="Send Message" name="submit2">
    
    </form>

  10. #10
    Join Date
    Mar 2007
    Location
    localhost
    Posts
    2,346
    Have had a look at the HTML, lots of errors and omissions.

    I have updated the JavaScript to take in to account your Option selector and made a change to it also

    Added Title tag and the <meta tag because firefox was being pedantic over character set
    <title>Fishy Business</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />

    Code:
    function echeck(o){ // o is the onsubmit="return echeck(this);" line in your form submit
    	event.preventDefault();
    	
    	var emailID		= o.EmailHome.value,
    		yourName	= o.YourName.value,
    		street		= o.StreetAddress.value,
    		city		= o.City.value,
    		county		= o.County[o.County.selectedIndex].value,
    		zip		= o.Zip.value,
    		msg		= o.message.value;	
    
    	if( yourName.length==0 ){
    		alert("Please Enter your Your Name");
    		o.YourName.focus();
    		return false;
    	}
    	  
    	var parts = emailID.split("@");
    	domain = parts.length>1 && parts[1].indexOf(".")>0 ? true : false;
    	if(!domain){
    		alert("Need Email Address");
    		o.EmailHome.focus();
    		return false;
    	}
    	
    	if ( street.length==0 ){
    		alert("Please Enter your Street Address");
    		o.StreetAddress.focus();
    		return false;
    	  }	
    	  
    	if ( city.length==0 ){
    		alert("Please Enter your City");
    		o.City.focus();
    		return false;
    	  }	
    	  
    	if ( zip.length==0 ){
    		alert("Please Enter your Zip Code");
    		o.Zip.focus();
    		return false;
    	  }	
    	
    	if( county==-1 ){
    		alert("Please Select your County");
    		o.County.focus();
    		return false;
    	}
    	
    	  	  
    	if ( msg.length==0 ){
    		alert("Please Enter your Your Message");
    		o.message.focus();
    		return false;
    	}
        
    	document.forms['form1'].submit();
     	return true;
    }
    HTML Code:
    <form method="post" id="form1" name="form1" action="somewheretogo.php" enctype="multipart/form-data" onsubmit="return echeck(this);" >
    Changed the form field to include an onsubmit, encode type for the server side processor, action and gave it a target to go to as you didn't indicate where the form posts to.

    HTML Code:
    <input name="YourName" size="16" type="text" value="" />
    Added to your tex inputs imortant information like the input type="text" and value="" which are needed in web forms.

    HTML Code:
    <select name="County" size="1">
        <option value="-1" selected>Please Select</option>
        <option>Bucks</option>
        <option>Chester</option>
        <option>Delaware</option>
        <option>Montgomery</option>
        <option>Philadelphia</option>
    </select>
    Needed a closing </select> tag and I added a Please Select option removed the values because your names will return as a value if not specified in a select but used value and set a -1 control value for it.

    HTML Code:
    <input class="button" type="submit" style="cursor: pointer;" value="Submit" name="submit">
    Changed this to a form button, removed your onclick, as I suspected you were passing form elements, my suggestion was to pass the form as a submit object. Web forms need a Submit button!

    I tried on my local web server the validation, which works quite well.

    Once you have made changes, you may find errors, I noted that Chrome (mine might need updating) wouldn't allow the .submit() as it claims that it is not a function, firefox would submit the form but moaned about irrelevant stuff that doesn't pose a real problem, I didn't try Opera as I find it operates much the same as firefox.

    Please let us know how you got on and in future pleas post your web code and not a link.
    Last edited by \\.\; 08-18-2014 at 11:21 AM.
    Yes, I know I'm about as subtle as being hit by a bus..(\\.\ Aug08)
    Yep... I say it like I see it, even if it is like a baseball bat in the nutz... (\\.\ Aug08)
    I want to leave this world the same way I came into it, Screaming, Incontinent & No memory!
    I laughed that hard I burst my colostomy bag... (\\.\ May03)
    Life for some is like a car accident... Mine is like a motorway pile up...

    Problems with Vista? :: Getting Cryptic wid it. :: The 'C' word! :: Whois?

  11. #11
    Join Date
    Nov 2006
    Posts
    229
    Thank You so much for your help. Unfortunately the textarea field is still not getting validated. I click on the submit button and nothing happens. By the way I am using Chrome. I also pasted the meta tag like you suggested.

  12. #12
    Join Date
    Oct 2013
    Posts
    484
    And in HTML5, no JavaScript required. A lot less code and mobile friendly to boot. I also got rid of the table:
    HTML Code:
    <!DOCTYPE html>
    <html lang="en">
    <head>
    <meta charset="UTF-8">
    <meta name="generator" content="A text editor, the way it should be done">
    <title>My form</title>
    <style>
    body {
    	background-color: #000;
    	color: #fff;
    }
    label {
    	margin-right: 0.5em;
    }
    #messageLabel, #messageHolder {
    	vertical-align: top;
    	float: left;
    }
    .red {
    	color: red;
    }
    .clear {
    	clear: both;
    }
    .button:hover {
    	cursor: pointer;
    }
    </style>
    </head>
    <body>
    
    <form method="post" name="form1" action="#">
    
     <div class="FREE_Offer_Form">
     
     <p><label for="name">Name</label><input type="text" id="name" name="YourName" size="16" required></p>
    
     <p><span class="red">**</span> <label for="phone">Phone</label><input type="tel" id="phone" name="PhoneNumber" size="15"></p>
     
     <p><label for="email">Email</label><input id="email" type="email" name="EmailHome" size="27" required></p>
           
     <p><label for="street">Street Address</label><input id="street" type="text" name="StreetAddress" size="27" required></p>
           
     <p><label for="city">City</label><input type="text" id="city" name="City" size="27" required></p>
           
     <p><label for="zip">Zip</label><input type="number" min="10000" id="zip" name="Zip" required></p>
           
     <p><label for="county">County</label><select id="county" name="County" required>
    		<option value="">Choose one</option>
    		<option value="Bucks">Bucks</option>
    		<option value="Chester">Chester</option>
    		<option value="Delaware">Delaware</option>
    		<option value="Montgomery">Montgomery</option>
    		<option value="Philadelphia">Philadelphia</option>
    	   </select></p>
           
     <div id="messageLabel"><label for="message">Message</label></div> <div id="messageHolder"><textarea id="message" name="message" cols="25" rows="7" required></textarea></div>
    
     <p class="red clear">** <i>Optional</i></p>
         
     </div>
     
    <input class="button" type="submit" value="Send Message" name="submit2">
    
    </form>
    
    </body>
    </html>
    Caveat: Some HTML5 form attributes don't work in older browsers (think IE8-). If it's important to support those you can incorporate the scripting provided by \\:\.

  13. #13
    Join Date
    Nov 2006
    Posts
    229
    Quote Originally Posted by Kevin2 View Post
    And in HTML5, no JavaScript required. A lot less code and mobile friendly to boot. I also got rid of the table:
    HTML Code:
    <!DOCTYPE html>
    <html lang="en">
    <head>
    <meta charset="UTF-8">
    <meta name="generator" content="A text editor, the way it should be done">
    <title>My form</title>
    <style>
    body {
    	background-color: #000;
    	color: #fff;
    }
    label {
    	margin-right: 0.5em;
    }
    #messageLabel, #messageHolder {
    	vertical-align: top;
    	float: left;
    }
    .red {
    	color: red;
    }
    .clear {
    	clear: both;
    }
    .button:hover {
    	cursor: pointer;
    }
    </style>
    </head>
    <body>
    
    <form method="post" name="form1" action="#">
    
     <div class="FREE_Offer_Form">
     
     <p><label for="name">Name</label><input type="text" id="name" name="YourName" size="16" required></p>
    
     <p><span class="red">**</span> <label for="phone">Phone</label><input type="tel" id="phone" name="PhoneNumber" size="15"></p>
     
     <p><label for="email">Email</label><input id="email" type="email" name="EmailHome" size="27" required></p>
           
     <p><label for="street">Street Address</label><input id="street" type="text" name="StreetAddress" size="27" required></p>
           
     <p><label for="city">City</label><input type="text" id="city" name="City" size="27" required></p>
           
     <p><label for="zip">Zip</label><input type="number" min="10000" id="zip" name="Zip" required></p>
           
     <p><label for="county">County</label><select id="county" name="County" required>
    		<option value="">Choose one</option>
    		<option value="Bucks">Bucks</option>
    		<option value="Chester">Chester</option>
    		<option value="Delaware">Delaware</option>
    		<option value="Montgomery">Montgomery</option>
    		<option value="Philadelphia">Philadelphia</option>
    	   </select></p>
           
     <div id="messageLabel"><label for="message">Message</label></div> <div id="messageHolder"><textarea id="message" name="message" cols="25" rows="7" required></textarea></div>
    
     <p class="red clear">** <i>Optional</i></p>
         
     </div>
     
    <input class="button" type="submit" value="Send Message" name="submit2">
    
    </form>
    
    </body>
    </html>
    Caveat: Some HTML5 form attributes don't work in older browsers (think IE8-). If it's important to support those you can incorporate the scripting provided by \\:\.
    This seems to be working in Chrome....Just have to check to see if Internet Explorer and Firefox comply as well. Thank You for your help.

  14. #14
    Join Date
    Nov 2006
    Posts
    229
    Quote Originally Posted by ASPSQLVB View Post
    This seems to be working in Chrome....Just have to check to see if Internet Explorer and Firefox comply as well. Thank You for your help.
    Like you said, it does not seem to validate any part of the form in IE8 and IE9.

  15. #15
    Join Date
    Nov 2006
    Posts
    229
    Quote Originally Posted by ASPSQLVB View Post
    Code:
    <script language="JavaScript">
    function setFocus() {
    			document.form1.YourName.focus();
    			}	
        
          function echeck(YourName, str, message) 
    	  {
    	  var emailID=document.form1.EmailHome.value
    	
        
    	  if ((YourName==null)||(YourName=="")){
    		alert("Please Enter your Your Name");
    		document.form1.YourName.focus()
    		return false
    	  }
    	  
    	    var at="@"
    		var dot="."
    		var lat=str.indexOf(at)
    		var lstr=str.length
    		var ldot=str.indexOf(dot)
    		if (str.indexOf(at)==-1){
    		   alert("Invalid E-mail ID")
    		   document.form1.EmailHome.focus()
    		   return false
    		}
    
    		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
    		   alert("Invalid E-mail ID")
    		   document.form1.EmailHome.focus()
    		   return false
    		}
    
    		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
    		    alert("Invalid E-mail ID")
    		    document.form1.EmailHome.focus()
    		    return false
    		}
    
    		 if (str.indexOf(at,(lat+1))!=-1){
    		    alert("Invalid E-mail ID")
    		    document.form1.EmailHome.focus()
    		    return false
    		 }
    
    		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
    		    alert("Invalid E-mail ID")
    		    document.form1.EmailHome.focus()
    		    return false
    		 }
    
    		 if (str.indexOf(dot,(lat+2))==-1){
    		    alert("Invalid E-mail ID")
    		    document.form1.EmailHome.focus()
    		    return false
    		 }
    		
    		 if (str.indexOf(" ")!=-1){
    		   alert("Invalid E-mail ID")
    		    document.form1.EmailHome.focus()
    		    return false
    		 }
    	
    	
    	
    	if ((form1.StreetAddress.value==null)||(form1.StreetAddress.value=="")){
    		alert("Please Enter your Street Address");
    		document.form1.StreetAddress.focus()
    		return false
    	  }	
    	  
    	  if ((form1.City.value==null)||(form1.City.value=="")){
    		alert("Please Enter your City");
    		document.form1.City.focus()
    		return false
    	  }	
    	 
    	 	  
    	  if ((form1.Zip.value==null)||(form1.Zip.value=="")){
    		alert("Please Enter your Zip Code");
    		document.form1.Zip.focus()
    		return false
    	  }	
    	
    		  	  
    	  if (form1.message.length == 0){
            alert("Please Enter your Your Message");
            form1.message.focus();
            return false
      }
        			 	
    		
    	 else
    	    {
            document.form1.submit()
     		 return true	
            }
        
         }
    	 
    
         </script>
    </HEAD>
    <BODY bgcolor="000000">
    
    <form method="post" name="form1" action="">
    
     <table class="FREE_Offer_Form">
     <tr>
      <td>
       *
      </td>
     </tr>
    
     <tr align="left">
      <td name="FirstName">
        <font color="ffffff">
             Name
            </font>
             *<input name="YourName" size="16">    
           </td>
          </tr>
         
         <tr align="left">
           <td>
            
             <font color="red">**</font>
             <font color="ffffff">Phone
             </font>
             <input name="PhoneNumber" size="15">       
           </td>
           </tr>
          
           <tr align="left">
           <td>
            <font color="ffffff">
             Email 
            </font>
             <input name="EmailHome" size="27">       
           </td>
           </tr>
           
           <tr align="left">
           <td>
            <font color="ffffff">
             Street Address
            </font>
             <input name="StreetAddress" size="27">       
           </td>
           </tr>
           
           <tr align="left">
           <td>
            <font color="ffffff">
             City
            </font>
             <input name="City" size="27">       
           </td>
           </tr>
           
           <tr align="left">
           <td>
            <font color="ffffff">
             Zip
            </font>
             <input name="Zip" size="27">       
           </td>
           </tr>
           
           
           <tr align="left">
           <td>
             <font color="ffffff">County
             </font>
              <select NAME="County" SIZE="1">
                <option value="Bucks">Bucks
    			<option VALUE="Chester">Chester
    			<option VALUE="Delaware">Delaware
    			<option VALUE="Montgomery">Montgomery
    			<option VALUE="Philadelphia">Philadelphia
    	   </td>
           </tr>
           
           <tr align="left">
            <td>
           <table width="200px" align="center">
            <td valign="top">
             <font color="ffffff" size="3">Message</font>
            </td>
            <td> 
              <textarea name="message" cols="25" rows="7">
              </textarea>  
             </td> 
            </table> 
            </td>
           </tr>
           
           <tr align="left">
           <td>
                  
             
            <font color="red">
             ** <i>Optional</i>
             </font>
            </td>
           </tr>
         
     </table>
    <input class="button" type="button" onmouseover"" style="cursor: pointer;" onclick="echeck(document.form1.YourName.value,document.form1.EmailHome.value,document.form1.PhoneNumber.value, document.form1.message.value)" value="Send Message" name="submit2">
    
    </form>
    Is there an easy solution to adding the necessary javascript code so the validating works in IE8 and IE9?

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles