Html 5 validation pattern not supported in safari browser

hi im stuck in this validation thing in CHROME IE MOZILLA browsers the html 5 validation and pattern are working great but its not working in safari browser the REQUIRED is working but not the patters like email or passwords or mobile so what can be done pls help

Can you show us your code?

form role="form" action="hero.php" method="post" class="registration-form" class="middle">
<div class="form-group">
<label class="sr-only" for="form-first-name">First name</label>
<input type="text" name="fname" placeholder="First name..." class="form-first-name form-control" id="form-first-name" required>< <div class="form-group">
<label class="sr-only" for="form-lastname">Lastname</label>
<input type="text" name="lname" placeholder="Last name..." class="form-last-name form-control" id="form-last-name" required>
 </div>
  <div class="form-group">

Off Topic

You need to format your code for it to show up correctly in your posts, @Mazhar_Shaikh.

You can highlight your code, then use the </> button in the editor window, which will format it.

Or you can place three backticks ``` (top left key on US/UK keyboards) on a line before your code, and three on a line after your code. I find this approach easier, but unfortunately some European and other keyboards don’t have that character.

thanks for telling :slight_smile: il make note of it

1 Like

Which version of Safari has the problem and in which operating system, please?

9.1 or any latest browser of safari it wont validate the pattern

Caniuse shows only partial support for the pattern attribute in Safari so I guess you will need to use js locally or rely on the server side validation routines.

You need to do that anyway. The HTML and JavaScript validations are only for the convenience of the visitor filling out the form to save them having to submit it before they find out about the errors - so if a browser doesn’t fully support the appropriate pattern then it is no different from the person having JavaScript turned off.

Enough browsers now support the HTML validations that unless you already have the JavaScript validation written, it is not worth wasting the time on adding JavaScript. The server side validations will detect any errors anyway (and that is where it has to work in order to ensure that only valid data gets processed).

2 Likes

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.