Amen
Amen

Reputation: 713

Need a regex that does not care if less than 6 characters are entered

I have this regex that cause my validation message to fire because it requires 6 characters. I need a Regex that allows any amount of characters:

var unFieldRegEx = /^(?=.*[a-zA-Z\d])(\w|[\.\@\-\?\,\&\''\/\_\""]){6,}$/;

Upvotes: 1

Views: 189

Answers (2)

Basic
Basic

Reputation: 26766

var unFieldRegEx = /^(?=.*[a-zA-Z\d])(\w|[\.\@\-\?\,\&\''\/\_\""])*$/;

should do it (remove the length specifier @ the end and replace with a *)

Upvotes: 1

CrayonViolent
CrayonViolent

Reputation: 32532

change {6,} to * for 0 or more characters. Change it to + for 1 or more characters.

Upvotes: 2

Related Questions