- Joined
- Mar 25, 2011
- Messages
- 9,563
I'm wanting to validate a required input by checking if:
I have tried this:
And it returns True if the value is not an empty string but it also returns True regardless of if the pattern is a match or not. Any idea on how to do this?
For what it's worth, here is the fiddle that I've been working on: http://codepen.io/anon/pen/XdbaBG
I'm making a step-by-step form.
- There is a value
- The value matches the pattern
I have tried this:
Code:
if($(this).val() === "" || ($(this).prop('pattern') !== "" && $(this).val().match($(this).prop('pattern'))))
And it returns True if the value is not an empty string but it also returns True regardless of if the pattern is a match or not. Any idea on how to do this?
For what it's worth, here is the fiddle that I've been working on: http://codepen.io/anon/pen/XdbaBG
I'm making a step-by-step form.