vérification champ vide en ajax
Bonjour, j'ai un formulaire php et je souhaiterai vérifier les champs vides et les colorer pour l'utilisateur. De plus je voudrais mettre un message lorsqu'un champs est vide.
mon formulaire ressemble brievement à cela :
form.php
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63
| <html xmlns="http://www.w3.org/1999/xhtml" lang="fr">
<head>
<title> Header Corpus</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="Content-Language" content="fr" />
<meta name="author" content="Kam" />
<script type="text/javascript" src="verifVIDE.js"> </script>
</head>
<body vlink="#0033CC" onload="hide();">
<div id="world">
<div id="head" align="center">
<h2 align="center">Fiche signalétique Corpus </h2>
<!--lien vers le script php permettant le post des valeurs -->
<?
include("insert.php");
?>
<table align="center" width=100% height=55%>
<tr>
<td><? echo $message; ?>
<form method="post" action="<? echo $URL; ?>"
name="formulaire" onSubmit="return testChamps(this);" enctype="multipart/form-data"
acceptcharset="utf-8">
<table bgcolor=white width="100%" border="1" cellspacing="8"
cellpadding="2" bordercolor="#CCCC33">
<tr>
<td>Nom du dossier contenant le corpus informatisé (identifiant):</td>
<td><input type="text" size="50" name="NomFichierSource" onblur="req_NomFichierSource(this.value);"> <span id="NomFichierSource_check"></span></td>
</tr>
<!-- infos CORPUS -->
<tr>
<td align="center"><b><i>Informations sur le corpus</i></b></td>
<td bgcolor="#006699"></td>
</tr>
</table>
</form>
</td>
</tr>
</table>
</div>
</div>
</body>
</html> |
j'ai fait un code javascript qui est : mais qui ne fonctionne pas
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
| function couleur(obj) {
obj.style.backgroundColor = "#FFFFFF";
}
function check() {
var msg = "";
if (document.NomFichierSource.nom.value == "") {
msg += "Veuillez saisir votre nom\n";
document.formulaire.NomFichierSource.backgroundColor = "red";
}
if (msg == "") return(true);
else {
alert(msg);
return(false);
}
} |
j'aimerai avoir une aide en ajax pour ce problème.
merci à vous,