By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
432,188 Members | 844 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 432,188 IT Pros & Developers. It's quick & easy.

Form validation/s fail in Internet Explorer only...

scubak1w1
P: 53
Hello,

I have a form that works like a charm - as long as you are not using Internet Explorer!

I made a new form (below, a *.php file) to show you how VALIDATION (two 'types') is failing in IE... Neither of the validations work in IE...

I tried to change the type="image" to a very simple type="submit" for the form submittal --- and a heck of a lot more things have been tried...

What am I missing?

I am primarily a scientific data analysis guy, geologist, self taught in all this - shows huh? <wink> - so please assume I am missing the easy stuff <smile>

Thanks in advance...
GREG...

Expand|Select|Wrap|Line Numbers
  1.  
  2. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  3. <html xmlns="http://www.w3.org/1999/xhtml">
  4.  
  5. <head>
  6.  
  7.     <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  8.  
  9.     <title>DELETE Page - Test Form - Bloody Internet Explorer</title>
  10.  
  11.     <script src="/SpryValidationTextField.js" type="text/javascript"></script>
  12.     <link href="/SpryValidationTextField.css" rel="stylesheet" type="text/css" />
  13.  
  14.  
  15.     <!-- form related javascript -->
  16.     <script language="javascript" type="application/javascript">
  17.  
  18.         var errorsOnSubmit = function(form)
  19.             {
  20.  
  21.                 var ret = Spry.Widget.Form.validate(form);
  22.  
  23.                 var errorZone= document.getElementById('error_zone');
  24.  
  25.                 if (!ret)
  26.                     {
  27.  
  28.                         errorZone.style.visibility = 'visible';
  29.  
  30.                         errorZone.style.backgroundColor = 'red';
  31.  
  32.                     }
  33.                     else
  34.                     {
  35.  
  36.                         errorZone.style.visibility = 'hidden';
  37.  
  38.                     };
  39.  
  40.                 return ret;
  41.  
  42.             };
  43.  
  44.         //validate the specific (sic) of the incident reporting form contents
  45.         function validate_try_simple_form_ie()
  46.             {
  47.  
  48.                 alert('Specific validation fired...');
  49.  
  50.                 //make sure my name is not used
  51.                 if(document.try_simple_form_ie.txt_full_name.value == 'Greg Cocks')
  52.                     {
  53.                         alert('Don\'t use my name!');
  54.                         document.try_simple_form_ie.txt_full_name.value = "";
  55.                         document.try_simple_form_ie.txt_full_name.focus();
  56.                         return false;
  57.                     };
  58.  
  59.                 //check out OK
  60.                 return true;
  61.  
  62.             };
  63.  
  64.     </script>
  65.  
  66.  
  67. </head>
  68.  
  69. <body>
  70.  
  71.     <h1 style="text-align:center;color:red">
  72.         DELETE Page - Test Form - Bloody Internet Explorer - 22
  73.     </h1>
  74.  
  75.     <p>
  76.         Form functionality that works like a charm in Chrome, Firefox, etc - but the Spry and the 'custom' validation does not work in IE!!
  77.         </p>
  78.  
  79.     <form action="<?php print $_SERVER['PHP_SELF']; ?>" method="post" name="try_simple_form_ie" id="try_simple_form_ie" onsubmit="return errorsOnSubmit(this);" >
  80.  
  81.         <input type="hidden" name="_try_simple_form_ie" value="1" />
  82.  
  83.         <label for="txt_full_name" style="font-weight:bold;font-size:0.8em">
  84.             Enter Full Name:
  85.         </label>
  86.         <br />
  87.         <span id="val_txt_full_name">
  88.             <input type="text" name="txt_full_name" size="25" />
  89.             <span class="textfieldRequiredMsg">
  90.                 A value is required.
  91.               </span>
  92.             <span class="textfieldMinCharsMsg">
  93.                 Minimum number of characters not met.
  94.               </span>
  95.           </span>
  96.         <br />
  97.         <br />
  98.  
  99.         <input
  100.             type="image"
  101.             src="http://bytes.com/images/icon_050_submit_button.png"
  102.             alt="Submit Form Details"
  103.             id="submit_form_details"
  104.             title="Submit The Information"
  105.             onclick="return validate_try_simple_form_ie()"
  106.         />
  107.  
  108.         <p class="clearIt" id="error_zone" style="visibility:hidden">
  109.             ERRORS: There are some ERROR/S in the form, shown in red shading of the field/s. Please scroll up, correct them, and resubmit...
  110.            </p>
  111.  
  112.     </form>
  113.  
  114.     <br />
  115.     <br />
  116.  
  117.     <?php
  118.  
  119.         //see if the form details have been submitted
  120.         if(array_key_exists('_try_simple_form_ie', $_POST))
  121.             {
  122.  
  123.                 print 'Name: '.$_POST['txt_full_name'].'<br />';
  124.  
  125.             };
  126.  
  127.  
  128.     ?>
  129.  
  130.  
  131. <script type="text/javascript">
  132.     var sprytextfield1 = new Spry.Widget.ValidationTextField("val_txt_full_name", "none", {validateOn:["blur", "change"], minChars:5});
  133. </script>
  134. </body>
  135.  
  136. </html>
  137.  
  138.  
Mar 22 '12 #1
Share this Question
Share on Google+
1 Reply


scubak1w1
P: 53
I popped up the simple version on a public page at http://www.stoller.com/a_test_form_pita_ie.php

Internet Explorer is the issue...

There are two types of validation when you hit submit...

(i) if you have not entered 5 characters in the text box, you should see "ERRORS: There are some ERROR/S in the form, shown in red shading of the field/s. Please scroll up, correct them, and resubmit..."

(ii) if you enter my name as in the text box, 'Greg Cocks', no quotes, it should say not to use my name and clear out the text box...

Cheers!
Mar 22 '12 #2

Post your reply

Sign in to post your reply or Sign up for a free account.