2 Replies Latest reply on Mar 8, 2012 1:21 PM by camilo umaña

    How to use a script for validate the same field with different addresses in different pages?

    camilo umaña Level 1

      I have a script applied to a field “email”.

      The script asks to check the address if it is not well written.

       

      But this field is present in many pages for different customers filling up this information.

       

      How may I adapt this script? (without changing the name of each field in each page and consequently changing the value in the script for that page...)

       

       

       

      function confirm_email_OnValidate (Element)

                {

                event.rc = confirm_email_Validate(Element, event.value);

                }

      function confirm_email_Validate (Element, newvalue)

                {

                if (newvalue.length <= 0)

                          return true;

                Dummy = newvalue.replace (/[a-zA-Z0-9]+((\.|_|\-)[a-zA-Z0-9]+)*@([a-zA-Z0-9]+(\.|\-))+[a-zA-Z]{2,}/, "");

                if (Dummy.length != 0)

                          {

                          InputError (Element, "Check this address");

                          return false;

                          }

                return true;

                }

      function confirm_email_Format (Element)

                {

                return true;

                }