1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
| <?php
if(isset($_POST)) {
$mots = array('voleurs','voleur');
$phrase = $_POST['desc'];
var_dump(preg_match('#\b(' . implode('|', $mots) . ')\b#', $phrase));
echo "<hr />";
}
?>
<form action="type.php" method="post">
<textarea name="desc" cols="100" rows="30"></textarea>
<input onclick="ValiderFormu(this.form)" style="background-image:url(images/general/bttn_ajouter.png);width:150px;height:25px;border:0;cursor:pointer; margin-top:10px; margin-bottom:10px; margin-left:110px;" type="button" value=" " alt=" " name="valider_form" />
</form>
</p>
</div>
<script type="text/javascript">
function ValiderFormu(formulaire) {
if (formulaire.desc.value=='') {alert("Merci de spécifier une description de ce commerce ou service.");}
else {formulaire.submit()}
}
</script> |