Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

Urgent !!! How to trim spaces of an email filed ?

bharathi_reddy
Level 3
Level 3

Hi,

I have an email field in a form ,which have a validation at the time of submission of form as shown in the below .

function isEmailValid(fld){

                    var result = true;

                    if(fld != null){

                              var r = new RegExp();

                        r.compile("^[a-z0-9_\\-\\.\\']+\\@[a-z0-9_\\-\\.]+\\.[a-z]{2,4}$","i");

                              result = r.test(fld.rawValue);

                    }

                    return result;

          }

but if user by mistakely enters the space in that field  at the time of validation it is  showing an error called "Invalid Email Format"

I need to trim those spaces either modifying the above regular expression or the best way

Please suggest ..

Thanks in Advance

Bharathi

1 Reply
dcidev
Level 8
Level 8

In the exit event of your email field put:

this.rawValue = this.rawValue.replace(/\s/g,"");

Kyle