开发者

Safari 5 won't submit a form with bad data in input type=email

With an input type=email, Safari won't let the form be submitted if there's not a valid email address. But there's no feedback from the browser at all to let the开发者_如何学运维 user know why the form stopped working.

Is there anything to be done other than writing some Javascript to validate the input (which kind of ruins the point of using type=email)?


Do styles show up?

input[type=email]:invalid {
    background-color: red;
}

If you resort to JavaScript, you don't need it to do the validation, you just need to hook into the HTML5 constrain validation API, either hook the invalid event or call element.validity.valid as you loop through the form on the submit event. There's a nice introduction to the whole thing on A List Apart: Forward Thinking Form Validation

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜