0

I'm trying to validate my XHTML 1.0 but I've got 2 error's which I can't seem to fix no matter what. Could someone just take a look at it and if so provide alternatives to it? When I change 'email' to text my JS stops working.

Line 49, Column 58: there is no attribute "required"

…id="first-name"  type="text" required="required" onkeypress="return onlyAlphab…


Error Line 63, Column 41: value of attribute "type" cannot be "email"; must be one of "text", "password", "checkbox", "radio", "submit", "reset", "file", "hidden", "image", "button"

2 Answers2

1

The "required" attribute and the "type=email" come with HTML5, your document use xhtml 1.0 strict.

You can :

  • change the doctype to HTML5 : <!DOCTYPE html>

or

  • remove those attribute / type :)
enguerranws
  • 8,087
  • 8
  • 49
  • 97
  • Is there any alternatives to it besides rewriting everything? –  Apr 30 '14 at 15:10
  • I just edited my answer : change your doctype or remove those part of code. – enguerranws Apr 30 '14 at 15:11
  • I'm trying to make it work with XHTML not with HTML5 :/ So there's no alternatives? Just have to re-write my JS? –  Apr 30 '14 at 15:13
  • I'm afraid there's no alternative : you wanna use HTML5 element in non-HTML5 document. The real question is : why you wanna make it work as XHTML 1 strict if you use HTML5 ? :) – enguerranws Apr 30 '14 at 15:14
  • Post your JS part if you want some help with that. – enguerranws Apr 30 '14 at 15:15
  • It's just a requirement that I want for my website to validate in XHTML1.0, but looks like that isn't happening :( –  Apr 30 '14 at 15:15
  • Cheers for that, I've added my JS –  Apr 30 '14 at 15:17
  • Thank you. What is this JS supposed to do on the email input ? Checking email ? If so, it's because type="email" process email validation by default (HTML5 feature). So you have to check this entirely with JS from now. This topic can help you : http://stackoverflow.com/questions/46155/validate-email-address-in-javascript – enguerranws Apr 30 '14 at 15:23
  • What should my type be? text or still email? –  Apr 30 '14 at 15:24
0

XHTML has no input of type email and has no form validation so required does not exists. Those are elements are added in HTML5

Volvox
  • 1,639
  • 1
  • 12
  • 10