Your function needs to be called through observe for this to work.
Something like this (untested):
document.observe('dom:loaded',
function() {
$('form_modifieremail').observe('submit', ModifierEmailCompte);
}
);
--
Jonathan Rosenberg
Founder & Executive Director
Tabby's Place
http://www.tabbysplace.org <http://www.tabbysplace.org/>
-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of Joannes De
KOSTER
Sent: Thursday, September 02, 2010 6:37 PM
To: Liste prototype
Subject: [Proto-Scripty] Form submit problem
Hello,
I have programmed a form and don't wan't it to "html" submit, so i try to
use Event.stop(event) . It doesn't seem to work after many tryouts. What do
i do wrong?
The form :
<form onsubmit="ModifierEmailCompte();" id="form_modifieremail"
name="form_modifieremail" method="post" action="fiche_joueur.fr.php">
<input type="text" value="[email protected]" class="saisietextecourt"
id="compteemail" name="compteemail" />
<button value="TRUE" name="btn_envoyer" class="boutonenvoyer" type="submit">
Modifier
</button>
<input type="hidden" value="[email protected]" id="emailorigine"
name="emailorigine" />
<input type="hidden" value="5238" name="id_user" />
<input type="hidden" value="modifieremail" name="action" />
</form>
The javascript :
function ModifierEmailCompte(event)
{
var emailRegEx = new RegExp(
"^\\w[\\w+\.\...@[\\w\-]+\.\\w[\\w+\.\-]*\\w$", "gi" ) ;
var email =$F('compteemail');
var email2 =$F('emailorigine');
if(email == "")
{
alert("Merci de saisir une adresse email avant de valider.");
}
else if(email.search(emailRegEx) == -1)
{
alert("L'adresse email saisie n'est pas valide.");
}
else if(email == email2)
{
alert("Veuillez modifier l'adresse email avant de valider.");
}
else
{
var url_ajax = 'fiche_joueur.emailmodifier.fr.php';
var target_ajax = 'modifieremail';
var params_ajax = Form.serialize("form_modifieremail");
new Ajax.Updater(
target_ajax,
url_ajax,
{
parameters: params_ajax,
onSuccess: function() { Effect.Fade.delay(3,
'messagemodifieremail'); },
onFailure: function() { alert('Une erreur est survenue lors
de la procédure ModifierEmailCompte.'); }
}
);
}
Event.stop(event);
}
Thanks for any help.
--
Joannes De KOSTER
Société DEFI SUD
--
You received this message because you are subscribed to the Google Groups
"Prototype & script.aculo.us" group.
To post to this group, send email to
[email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/prototype-scriptaculous?hl=en.
--
You received this message because you are subscribed to the Google Groups
"Prototype & script.aculo.us" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/prototype-scriptaculous?hl=en.