We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 20728
    • 53 Posts
    Hi,

    I’ve noticed an issue that when form fields have a default value (e.g. an email field might have a default value "Please enter your email address"), the eForm required field validation fails as it thinks the field has been completed.

    Looking at the code I could probably modify it so if the field starts with "Please" the validation would still fire but it’s not an ideal solution.

    I know I could just remove the default value but it’s a worthwhile addition for accessibility.

    If anyone can offer a solution I would be most grateful!

    Regards,

    Mike
      Enovate Design | Web Design Agency Essex
      • 20728
      • 53 Posts
      As a workaround I’ve edited the eform.inc.php file which is doing the job for the time being:

      At line 193 I changed this:

      if ($isRequired==1 && $value=="" && $datatype!="file"){


      To this:

      if ($isRequired==1 && $datatype!="file" && ($value=="" || strpos($value, "Please ") === 0)){


      And also again at line 197 I changed this:

      }elseif( isset($fld[5]) && $value!="" && $datatype!="file" ) {


      To this:

      }elseif( isset($fld[5]) && $datatype!="file" && ($value!="" || strpos($value, "Please ") !== 0)) {


      The best solution would just be to compare $value with the default value of the input field, this is easy to do in JavaScript but I have no idea in PHP.

      I suppose one option might be to use some JS to clear the form fields that have default text before the form is submitted but again these are hacks rather than a solution.

      Can anyone help?
        Enovate Design | Web Design Agency Essex
        • 20728
        • 53 Posts
        Just wondering if anyone has any ideas on this seeing as it’s still a problem.
          Enovate Design | Web Design Agency Essex