1

I am having a stupid issue with a form. I have always used the 'required' attribute in an input box for quick validation, but now for some reason when I am using a button instead, the validation is not running? Does it just not work with a button or am i doing something wrong? Something that could be causing issues, is that the the required fields are sometimes readonly. Is there maybe a conflict? Below is some example code:

This would be my input box:

<input type='text' id='something' name='something' required />

and this would be my submit:

<input type='submit' value='Submit' />

But now I am trying to use this:

<button type='submit'>Submit</button>

Thanks in advance. Any help would really be appreciated.

8
  • 2
    Which browsers do you see this problem with? Commented Jul 4, 2012 at 17:43
  • I'm developing in Firefox. I added to the question though, that maybe is it because it would be readonly as well sometimes? Commented Jul 4, 2012 at 17:45
  • Have you got a jsfiddle? Commented Jul 4, 2012 at 17:50
  • Works fine for me (tried latest Chrome and Firefox): jsfiddle.net/rjhbD/1 Commented Jul 4, 2012 at 17:52
  • 2
    Would it not be easiest simply to remove the readonly property in the submit() method/handler? Commented Jul 4, 2012 at 20:09

1 Answer 1

1

For anyone experiencing the same issue, you cannot have required and readonly in an input field. Just try do without or maybe use some JavaScript to help out.

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.