Alejandro
Alejandro

Reputation: 1159

type email in safari

I have a form:

<form action="something.php" method="POST">
  <input type="email" name="email"/>
  <input type="submit" value="Send Email"/>
</form>

When someone tries to input some string that is not in email format the form won't let him. The only problem is that this dosen't work on Safari! Why!!!! http://www.w3schools.com/html/html5_form_input_types.asp

So what super easy work around can I use? Thank you

Upvotes: 0

Views: 1859

Answers (1)

zneak
zneak

Reputation: 138231

Let's be very clear on this point: while some HTML clients will respect the input type, several won't, and even if they do, it will not prevent anyone from forging an HTTP request where this field is not an email address. Therefore, you can rely on <input type=email> to provide a hint to users as to what should go in that field, but you shouldn't rely on it to make sure that only email addresses make it to your PHP script.

So some browsers support it, but Safari doesn't. That's pretty much all there is to it.

The correct solution, then, is to also do server-side validation and make it fail if it's not an email address. You can relatively easily check that with regular expressions.

Upvotes: 2

Related Questions