Pb verif formulaire

MarsL Messages postés 17 Date d'inscription jeudi 15 mai 2003 Statut Membre Dernière intervention 11 mai 2004 - 22 déc. 2003 à 09:43
MarsL Messages postés 17 Date d'inscription jeudi 15 mai 2003 Statut Membre Dernière intervention 11 mai 2004 - 22 déc. 2003 à 13:02
J'ai un formualire avec le premier champs obligatoire de type texte et qui ne doit pas etre nul.
Actuellement je vérifie juste s'il n'est pas nul.
Et lorsque je clic sur submit il me fait bien l'alert mais m'envoie qd meme mon formulaire.
Voici le code :
<html>
<head>
<link rel= "stylesheet" href="/LGAppli/css/default.css" type="text/css">
<title>CREATION D'UNE APPLICATION</title>
<script LANGUAGE="JavaScript">
function verif() {
nom=document.forms[0].elements[0].value;
if(nom == "") {
alert("Indiquez le nom de l'application, SVP.");
}
return(false);
}

</script>

</head>

<table width="670" border="1" cellspacing="0">
----,
Ajout Application
</td>

<!-- ----

$!vm_resultat

,
-->
----

<form name ="form1" method="GET" OnSubmit="javascript:verif()" action="/LGAppli/servlet/LGAppli_application_insertion2">
<table width="640" border="1" align="center" cellspacing="0">
----, Nom
</td>

,

----

Version
,

,

----

Description
,

<textarea name="appli_description" cols=30 rows=3></textarea>,

(...)
----

,
Fax
,


<!-- -->

</form>
</td>
</tr>
<tr>
<td height="25" bgcolor="#CCCCCC">Précèdent,
Menu
</td>
</tr>
</table></td>
</tr>
</table>

</html>

S ke qq'1 peut me dire pourquoi il passe a la page suivante donc fait l'action du form alors que je lui ai mis un return false

Merci
et aussi comment vérifier qu'il s'agit bien d'un tuype texte sans caracteres speciaux ni espace.



Mars'L

2 réponses

cs_bultez Messages postés 13615 Date d'inscription jeudi 13 février 2003 Statut Membre Dernière intervention 15 octobre 2013 30
22 déc. 2003 à 11:26
Bonjour

si on clique sur submit : il se fait

donc cliquer sur autre chose,
tester,
si bon : simuler click sur submit,
si erreur : message

modif faites :

<head>
<link rel= "stylesheet" href="/LGAppli/css/default.css" type="text/css">
<title>CREATION D'UNE APPLICATION</title>
<script LANGUAGE="JavaScript">

function verif() {
nom=document.forms[0].elements[0].value;
if(nom == "")
{ alert("Indiquez le nom de l'application, SVP."); }
else { form1.bouton_creer.click(); } }

</script>

</head>

<table width="670" border="1" cellspacing="0">
----,
Ajout Application
</td>

<!-- ----

$!vm_resultat

,
-->
----

<form name ="form1" method="GET" action="/LGAppli/servlet/LGAppli_application_insertion2">
<table width="640" border="1" align="center" cellspacing="0">
----, Nom
</td>

,

----

Version
,

,

----

Description
,

<textarea name="appli_description" cols=30 rows=3></textarea>,

(...)
----

,
Fax
,

<!-- -->

</form>
</td>
</tr>
<tr>
<td height="25" bgcolor="#CCCCCC">Précèdent,
Menu
</td>
</tr>
</table></td>
</tr>
</table>
</html>

Cordialement. Bul.
0
MarsL Messages postés 17 Date d'inscription jeudi 15 mai 2003 Statut Membre Dernière intervention 11 mai 2004
22 déc. 2003 à 13:02
c bon g trouvé l'erreur
en fait il fallait que je fasse OnSubmit="return verfi();"
merci qd mem

Mars'L
0
Rejoignez-nous