How to use trimmed value for username validation

Hi, I want to allow the username to add either whitespace before or after text and for this not to be included in the validation and not add up to the character count. How can this be achieved with my current regex pattern?

<input id="text1" type="text" accept="text/plain" autocomplete="off" data-msg-min="" data-msg-equalto="" data-msg-unicodelettersonly="" data-msg-pattern="oops" data-rule-pattern="^[a-zA-Z0-9][a-zA-Z0-9]*([._-][a-zA-Z0-9]+){3,15}$" data-msg-maxlength="" data-msg-minlength="" maxlength="15">

With this regex “Usernames can be 3 to 15 characters long, must start with a letter or number & can include these three special characters . - _ but not consecutively.

So for example these inputs should only equal to 4 characters and be accepted value.

image

image

Community Page
Last updated: