4

I'm using the HTML5 pattern attribute in an <input> to return a match for a specific string: 'felfogtam'

My current markup is:

<input type="text" class="input input-small" pattern="felfogtam">

It does work, but the input is still valid if the field is empty. How can I change the regular expression to not allow a blank field?

2
  • If you post a working example of your code to a jsfiddle it will help with finding a solution. Commented Dec 31, 2012 at 22:51
  • 1
    @ZackT. I'm aware that jsFiddle exists, and I was sure that this code is simple enought to not use it. Commented Dec 31, 2012 at 22:52

1 Answer 1

6

Add the required attribute

<input type="text" class="input input-small" pattern="felfogtam" required>

http://jsfiddle.net/bJU2D/

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.