I'm trying to add a "required" attribute to some inputs in my form, but it just doesn't work. The only way it can work is by removing the "value" attribute from the input, but its necessary.
<form id="contact-form" method="POST" action=" <?php echo htmlspecialchars($_SERVER[" PHP_SELF "]) ?>" role="form">
<div class="row">
<div class="col-md-6">
<label for="firstname">Prenom<span class="blue">*</span></label>
<input type="text" name="firstname" class="form-control" placeholder="votre prenom" value=" <?php echo $firstname ?>" required>
<p class="comments">Message d'erreur</p>
</div>
<div class="col-md-6">
<label for="lastname">Nom<span class="blue">*</span></label>
<input type="text" name="lastname" class="form-control" placeholder="votre nom" value=" <?php echo $name ?>" required>
<p class="comments">Message d'erreur</p>
</div>
<div class="col-md-6">
<label for="email">Email<span class="blue">*</span></label>
<input type="text" name="email" class="form-control" placeholder="votre email" value=" <?php echo $email ?>" required>
<p class="comments">Message d'erreur</p>
</div>
<div class="col-md-6">
<label for="phone">Téléphone<span class="blue"></span></label>
<input type="text" name="phone" class="form-control" placeholder="votre email" value=" <?php echo $phone ?>">
<p class="comments">Message d'erreur</p>
</div>
<div class="col-md-12">
<label for="name">Message<span class="blue"></span></label>
<textarea id="message" name="message" class="form-control" placeholder="Votre message" rows="3" value=" <?php echo $message ?>"></textarea>
<p class="comments">Message d'erreur</p>
</div>
<div class="col-md-12">
<p class="blue"><strong>*Ces informations sont requises</strong></p>
</div>
<div class="col-md-12">
<input type="submit" class="button" value="envoyer">
</div>
</div>
<p class="thankyou">Votre message a été bien envoyé, Merci de m'avoir contacté</p>
</form>
actually, if i remove the "value" attribute, it'll work perfectly... Does anyone knows why this happens ? And how can i keep the value attribute and get "required" working ?