I hate IE so much

Discussion in 'JavaScript' started by oo7ml, Jun 20, 2007.

  1. #1
    My form has as follows:

    email
    upload file (photo)
    about me (text area of 500 characters)

    When i load my page in IE, and enter the email address only and then click submit, i get the validation error message (please upload a photo becasue i left the file field blank, then if i enter just one character in the file field (which is all the validation asks for) the form does nothing when i click the submit button. This only happens in IE........... can anyone see why, thanks

    Here is my form

    
    <form name="registration" id="Upload" action="<?php echo $uploadHandler ?>" onSubmit="return validate_form(this);" enctype="multipart/form-data" method="post"> 
              <table width="77%" border="0" cellspacing="1" cellpadding="0">
    <tr bgcolor="#D9D9D8"> 
                  <td class="form">Email:</td>
                  <td><input type="text" name="email" size="32" maxlength="49">
                  <img src="images/info.gif"> 
                    <span class="form_small_text_2">Valid email address required</span></td>
                </tr>
                <tr bgcolor="#D9D9D8"> 
                  <td class="form">Submit Your Photo:</td>
                  <td class="text"><input type="hidden" name="MAX_FILE_SIZE" value="<?php echo $max_file_size ?>" /> 
                    <input id="file" type="file" name="file"  size="40"/>
    				<a class="linksHeader" href="read_me.php" onClick="NewWindow(this.href,'mywin','490','420','yes','center');return false" onFocus="this.blur()">Read Me</a>			</td>
                </tr>
    			
                <tr bgcolor="#D9D9D8"> 
                  <td class="form">About Me:</td>
                  <td colspan="2" class="text">
    			  <textarea cols="60" rows="8" name="about_me" class="form_small_text_3" wrap="physical" 
    				onKeyDown="textCounter(this.form.about_me,this.form.remLen,500);"
    				onKeyUp="textCounter(this.form.about_me,this.form.remLen,500); "onFocus="this.value=''; this.onfocus=null;">(Please keep this section FUN, CLEAN and REAL - your Photo and "Splash" details will be monitored on an ongoing basis - so don't be bold!)</textarea>
    			  <br>
                    <span class="form_small_text">Characters remaining: 
                    <input readonly type=text name=remLen size=3 maxlength=3 value="500">
                    </span><img src="images/info.gif"> 
                    <span class="form_small_text_2">Must be at least 1 sentance</span></td>
                </tr>
                <tr bgcolor="#D9D9D8"> 
                  <td height="35">&nbsp;</td>
                  <td> <input name="submit" type="submit" id="submit" value="Create my Account"> 
                    <input type="reset" name="Reset" value="Reset"></td>
                </tr>
    </table>
    </form>
    
    HTML:

    Here is my javascript validation:

    function validate_email(field,alerttxt)
    {
    with (field)
    {
    if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(registration.email.value))
    {return (true);}
    else {alert(alerttxt);return false};

    }
    }

    function validate_file(field,alerttxt)
    {
    with (field)
    {
    numofchar=value.length;
    if (numofchar<1)
    {alert(alerttxt);return false}
    else {return true}
    }
    }

    function validate_about_me(field,alerttxt)
    {
    with (field)
    {
    numofchar=value.length;
    if (numofchar<1)
    {alert(alerttxt);return false}
    else {return true}
    }
    }



    function validate_form(thisform)
    {
    with (thisform)
    {

    if (validate_email(email,"Ooops... Please enter a valid Email address")==false)
    {email.focus();return false}
    if (validate_file(file,"Ooops... You left out the most important part... Please upload a Photo")==false)
    {file.focus();return false}
    if (validate_about_me(about_me,"Ooops... About Me section must be 1 - 500 characters in length")==false)
    {about_me.focus();return false}
     
    oo7ml, Jun 20, 2007 IP
  2. oo7ml

    oo7ml Well-Known Member

    Messages:
    656
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    105
    #2
    Can you or somone evaluate a little more please please please...

    Can someone convert my code below to the format above so that i can check it, i'm desperate to get this working. Below is the validation for my password field. Can you conver it to the method above. Thanks a million to who ever gets it working

    function validate_password(field,alerttxt)
    	{
    		with (field)
    			{
    				if (!value.match(/^[a-z0-9]{5,20}$/i))  
    					  {alert(alerttxt);return false}
    				else {return true}
    			}
    	}
    HTML:

    function validate_form(thisform)
    {
    	with (thisform)
    	{
    
    		 if (validate_password(password,"Ooops... Password must be 5 - 20 characters in length (a-z 0-9 characters only)")==false)
    		  {password.focus();return false}
    	}
    }
    HTML:
     
    oo7ml, Jun 20, 2007 IP