Forum

November 2nd, 2014
A A A
Avatar

Lost password?
Advanced Search

— Forum Scope —




— Match —





— Forum Options —





Minimum search word length is 3 characters - maximum search word length is 84 characters

The forums are currently locked and only available for read only access
sp_Feed Topic RSS sp_TopicIcon
Regexp validation
23/10/2009
06:46
Avatar
Yajo
Guest
Guests

I think it will be very easy and not too hard to implement input validation by passing a string to use as a regexp. For example, a colmodel could be like:

...

 colModel:{

  editrules:{

   regexpPattern: '^[xy0-9]\\d{7}[a-z]$',

   regexpFlags: 'i',

   regexpMessage: 'The value must be X or Y followed by 7 numbers and a letter, or 8 numbers and a letter'

  }

 }

This will work for a spanish ID, for example.

This is approximately the function you should put at the end of any other validations:

if(colModel.editrules.regexpPattern != null && RegExp(colModel.editrules.regexpPattern, colModel.editrules.regexpFlags).test($(input_element).val())) raise_error(colModel.editrules.regexpMessage);

¿What do you think of the idea?

23/10/2009
11:15
Avatar
tony
Sofia, Bulgaria
Moderator
Members

Moderators
Forum Posts: 7721
Member Since:
30/10/2007
sp_UserOfflineSmall Offline

Hello,

No need to to do it so complex. Also the 3.6 version offers a custom validation where you can do it simple like this:

colModel: [

...

{ name :'some',..., editrules : {custom:true, custom_func: myfunc ... },

..

]

Where myfunc should return true or false depending on your need. See the 3.6 demos

Regards

Tony

For professional UI suites for Java Script and PHP visit us at our commercial products site - guriddo.net - by the very same guys that created jqGrid.

26/10/2009
06:57
Avatar
Yajo
Guest
Guests

I saw it, but i'm sending automatically-generated json data from a PHP class to generate the grids, and the json parser can't send functions, so it would be more helpful for me the regexp option because it's only string-based.

Anyway, it's just an idea, if you think it's unnecessary, I can implement it by myself.

Thanks for all!

Forum Timezone: Europe/Sofia

Most Users Ever Online: 715

Currently Online:
57 Guest(s)

Currently Browsing this Page:
1 Guest(s)

Top Posters:

OlegK: 1255

markw65: 179

kobruleht: 144

phicarre: 132

YamilBracho: 124

Renso: 118

Member Stats:

Guest Posters: 447

Members: 11373

Moderators: 2

Admins: 1

Forum Stats:

Groups: 1

Forums: 8

Topics: 10592

Posts: 31289

Newest Members:

, razia, Prankie, psky, praveen neelam, greg.valainis@pa-tech.com

Moderators: tony: 7721, Rumen[Trirand]: 81

Administrators: admin: 66

Comments are closed.
Privacy Policy   Terms and Conditions   Contact Information