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 the spaces that in the text fileds?

Level 3
Level 3

Hi ,

I have an email field .If a  person enter the value in to the field along with space i need to validate that field by removing spaces.

I already have validation for this email field as shown below..

function isEmailValid(fld){

                    var result = true;

                    if(fld != null){

                              var r = new RegExp();


                              result = r.test(fld.rawValue);


                    return result;


suggest the best how i will do that

Thanks in advance


1 Reply
Level 10
Level 10

Hi Bharathi,

I use this JavaScript function to trim whitespace.

function trimWhitespace(value)              


    if (value.replace)

        return value.replace(/^\s*(.*?)\s*$/, '$1');


        return value;


Hope it helps,