venerdì 30 novembre 2007

Custom validators and Nokia Browser

On SkakkiNostri, we have a custom RequiredFieldValidator for a custom control that basically boils down to a textarea. We had a bug report stating that people using the Nokia S60 built-in browser always failed the required field validation. Well, it turns out that the standard .net ValidatorTrim function simply does not work there, probably has something to do with the order of loading of scripts, or maybe our code isn't perfect (I did not try to write a test case, and standard RequiredFieldValidators work just fine). Since I do not have much time at all, I just wrote a simple TrimString function and now we can post messages in SkakkiNostri's forum using the Nokia Browser :)


// On Nokia Browser, the .net ValidatorTrim always returns null.
function TrimString(s) { return s.replace(/^\s+/g, "").replace(/\s+$/g, ""); }