There is my code i check a simple formulmary and i test with a function if my label "prenom" is empty or not. But when i test it's ok but the page is refreshing and so everything you wrote is destruct. How can i stop the process until the script is write ? thank you
<!--
/** * Formulaire classique */
-->
<html lang="fr">
<head>
<title>Formulaire</title>
<meta charset="utf-8">
<link href="style_form.css" rel="stylesheet" media="all" type="text/css">
</head>
<body>
<h1>Votre avis</h1>
<form id="form" method="post" enctype="text/plain">
<p>
<label for="prenom">Prénom</label><input id="prenom" type="text" name="prenom" value=" ">
<label for="nom">Nom</label><input id="nom" type="text" name="nom" value=" "><br>
<input id="sexeHomme" type="radio" name="sexe" value="homme"><label for="sexeHomme">Homme</label>
<input id="sexeFemme" type="radio" name="sexe" value="femme"><label for="sexeFemme">Femme</label><br>
<textarea name="impression" rows="5" cols="50">Donnez vos impressions sur le site...</textarea><br>
<button onclick="myFunction()">Envoyer</button>
<script>
function myFunction() {
var prenom;
if (prenom.trim() == "") {
console.log("Le labbel est vide");
}
}
</script>
</p>
</form>
</body>
</html>
/** here is the probleme