No announcement yet.

Grid search validation for MAC Address

  • Filter
  • Time
  • Show
Clear All
new posts

  • 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.


  • #2
    A mac address is 48 bit or 64 bit (see
    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...
    Enough info to get this working I guess.


    • #3
      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.




      • #4
        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.


        • #5
          Thanks for your idea!