Salut j’ai un problème avec le code suivent (javascript) :
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Document sans nom</title>
<script>
function validefrm()
{
alert("validefrm");
return true;
}
function validemessage()
{
alert("validemessage");
return false;
}
function inisial_frm()
{
document.getElementById("form1").setAttribute("action","xxxxx.html" )
//alert(document.form1.onsubmit);
document.getElementById("form1").setAttribute("onsubmit","javascript:return validefrm();" );
//alert(document.form1.onsubmit);
}
function apercu_frm()
{
document.getElementById("form1").setAttribute("action","yyyyyy.html" );
document.getElementById("form1").setAttribute("onsubmit","javascript:return validemessage();" );
}
</script>
</head>
<body>
<form id="form1" name="form1" method="post" action="" onsubmit="javascript:return validefrm();">
<label for="button"></label>
<input type="submit" name="button1" id="button1" value="Envoyer" onkeyup="inisial_frm()" onmouseover="inisial_frm()"/><br/>
<br/>
<br/>
<br/>
<input type="submit" name="button2" id="button2" value="Apercu" onkeyup="apercu_frm()" onmouseover="apercu_frm()"/>
</form>
</body>
</html>
Avent d’envoyer form1 je doit faire des test de validation avec validefrm() et validemessage() ,aucun problème avec c’est deux fonctions .mais problème se trouve dans les fonctions inisial_frm() et apercu_frm() lorsque je change l’attribut onsubmit sa valeur change mais les fonction ne marche pas.
Quand je désactive les deux commentaire voila ce qu’il ma fiche :
function anonymous()
{
return validefrm();
}
Ensuit:
javascript:return validefrm();
merci d'avance!!!
Afficher la suite