Grid search validation for MAC Address

Dear all,

I need to validate in a search of Grid, that the text field be a MAC address, I think in a regular expression, but I don’t know how to include the code on this field.

I appreciate ideas.

Regards.

A mac address is 48 bit or 64 bit (see https://en.wikipedia.org/wiki/MAC_address).
So it is not clear what you want. It first depends on hwo you store it (text? 18 characters long only 0…9 a…f and
in the form.
It depends what you exactly want…
Links: http://www.tutorialspoint.com/mysql/mysql-regexps.htm
http://stackoverflow.com/questions/4260467/what-is-a-regular-expression-for-a-mac-address
Enough info to get this working I guess.

Thanks for your answer.

The mac that I want save, is MAC-48 6 octets separated by - ie, A1-A1-A1-A1-A1-A1, in database a varchar(17), then, I want to validate in the search field of grid, that the value will be like a MAC in this format. I found that in Advanced Search,exist a event “onValidate”, I think that in this event, I could put some php code to validate with a regexp if the value put by the end user in the field, have this format, I’ll try, but, I want to validate also, when the end user is writing in the field, like a AJAX event.

Ideas?

Regards,

in the onvalidate is the right choice.
I would on the other hand not try to correct whilst they type it in (which is possible in sc with some extra javascript).
I would make a routine that:
-converts to uppercase
-cuts out any character not in 0…9 A…F
-checks if is then 6 octets long
-if so then the OnValidate succeeds and I insert the - back in the string on the right places if not I give an error.

Thanks for your idea!

Regards,