Regular Expression

I need this to allow uppercase caps only, with a blank entry required.  


But it seems to give error if the entry field is blank.  

Any suggestions on this would be welcome

Who is Participating?
stanscott2Connect With a Mentor Commented:
Do it like this:

var str = "";

A true condition means that either a non-caps character is present, or the string is empty.
netsmithcentralConnect With a Mentor Commented:
Not sure exactly what you need, so here's some for you:

Allow any number of capital letters (or a blank field):

Allow any number of capital letters, no blank field:

Allow exactly one capital letter (or a blank):

Allow exactly one capital letter, no blank field:

These last two are NOT available in all flavors of regular expressions.  Javascript allows them, others may or may not.
Allow x capital letters, (or a blank field):

Allow x capital letters, no blank field:
codequestAuthor Commented:
Thanks for inputs, that should do it.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.