VMware Cloud Community
JakeP
Enthusiast
Enthusiast
Jump to solution

Validation on a Text Box custom property?

What I'm trying to do is restrict a custom property text box so that the user can enter a max of 5 characters. Is there a way to validate? Using regex?

Thanks,

Jake

0 Kudos
1 Solution

Accepted Solutions
JakeP
Enthusiast
Enthusiast
Jump to solution

Sure, the expression I used in vCAC for my text box was: ([a-z,A-Z,0-9]{1,5})

The first part of the expression [a-z,A-Z,0-9] states that the letters A-Z can be used, lower or upper case, as well as the numbers 0-9. The second section {1,5} controls the length, as the entry must be between 1 and 5 characters total to validate.

If you plug it in to the site I mentioned above you can test your expression and how it evaluates.

Hope that helps.

-Jake

View solution in original post

0 Kudos
3 Replies
JakeP
Enthusiast
Enthusiast
Jump to solution

I was able to figure it out using RegEx. This site was helpful to build the expression:

http://www.regexr.com/

nsldg
Contributor
Contributor
Jump to solution

Hello, I was wondering if you could give an example of how you got this to work. I haven't worked with regex before and I have the same issue with needing to control what goes into a textbox (no special character, uppercase ect.).

0 Kudos
JakeP
Enthusiast
Enthusiast
Jump to solution

Sure, the expression I used in vCAC for my text box was: ([a-z,A-Z,0-9]{1,5})

The first part of the expression [a-z,A-Z,0-9] states that the letters A-Z can be used, lower or upper case, as well as the numbers 0-9. The second section {1,5} controls the length, as the entry must be between 1 and 5 characters total to validate.

If you plug it in to the site I mentioned above you can test your expression and how it evaluates.

Hope that helps.

-Jake

0 Kudos