Before Applying Smart Client Validation to Trim Value

Hi Isomorphic,

We are required to trim value before applying SC Validation let’s say “regexp” type. So How can we achieve this. For now we are using some thing like :-

{
											     type:"CustomRegexpUserPref2",errorMessage:" problem ",
											     condition:function (item, validator, value) {
												        if (fnReplaceNullByEmpty(fnTrim(value)).match(/\d/)){
												           return false;
												        } 
												        else
												          return true; 
												  },
												  stopIfFalse:true
										}

Please Suggest.

Unable to use type:“regexp” Validator

Hi Isomorphic,

Due to above requirement of trimming value for ex:- Last Name, we are unable to use type:“regexp” Validator. And we have to develop Custom Validators like above post.

Please suggest any solution, so that we can use type:“regexp” Validator.

Thanks for Support.

regexp validators and the “mask” validator can handle trimming whitespace. You just need to make whitespace optional on either side of the expression. Grab a good book or tutorial on regular expressions.

Tried Regular Expression

Hi Isomorphic,

I Tried Regular Expression , but unable to achieve the exact requirement,

I did:-

validators:[{type:"mask",mask:"/^\s+|\s+$/''/g",transformTo:"/\d/"}]

and also vice versa :-

validators:[{type:"mask",mask:"/\d/",transformTo:"/^\s+|\s+$/''/g"}]

But no success.

Can you please show an example.

Thanks For your help.

Your regular expressions are wrong. In a String, they should not have leading and trailing “/”. Just get a good tutorial on regular expressions and work out what you want, this isn’t SmartClient-specific.