Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> [JavaScript]wysyłanie formulasza jquery/javascrit
kemes123
post 8.07.2012, 18:38:15
Post #1





Grupa: Zarejestrowani
Postów: 28
Pomógł: 0
Dołączył: 15.04.2010

Ostrzeżenie: (0%)
-----


Witam

Pobrałem formularz http://tympanus.net/codrops/2010/03/12/php...rm-with-jquery/wysyłania wiadomości email raz dopisania rekordu do bazy. Wszystko jest ok ale chcę wyeliminować wysyłanie wiadomości poprzez naciśnięcie enter. Z uwagi na to że javascript to temat zupełnie nie znany proszę o pomoc:


  1. $(document).ready(function() {
  2. contact.initEventHandlers();
  3. });
  4. var contact = {
  5. initEventHandlers : function() {
  6. /* clicking the submit form */
  7. $('#send').bind('click',function(event){
  8. $('#loader').show();
  9. setTimeout('contact.ContactFormSubmit()',500);
  10. });
  11. /* remove messages when user wants to correct (focus on the input) */
  12. $('.inplaceError',$('#ContactForm')).bind('focus',function(){
  13. var $this = $(this);
  14. var $error_elem = $this.next();
  15. if($error_elem.length)
  16. $error_elem.fadeOut(function(){$(this).empty()});
  17. $('#success_message').empty();
  18. });
  19. /* user presses enter - submits form *//*
  20. $('#ContactForm input,#ContactForm textarea').keypress(function (e) {
  21. if ((e.which && e.which == 13) || (e.keyCode && e.keyCode == 13)) {
  22. $("#send").click();
  23. return false;
  24. }
  25. else
  26. return true;
  27. });*/
  28. },
  29. ContactFormSubmit : function() {
  30. $.ajax({
  31. type : 'POST',
  32. url : 'php/contact.php?ts='+new Date().getTime(),
  33. dataType : 'json',
  34. data : $('#ContactForm').serialize(),
  35. success : function(data,textStatus){
  36. //hide the ajax loader
  37. $('#loader').hide();
  38. if(data.result == '1'){
  39. //show success message
  40. $('#success_message').empty().html('Message sent');
  41. //reset all form fields
  42. $('#ContactForm')[0].reset();
  43. //envelope animation
  44. $('#envelope').stop().show().animate({'marginTop':'-175px','marginLeft':'-246px','width':'492px','height':'350px','opacity':'0'},function(){
  45. $(this).css({'width':'246px','height':'175px','margin-left':'-123px','margin-top':'-88px','opacity':'1','display':'none'});
  46. });
  47. }
  48. else if(data.result == '-1'){
  49. for(var i=0; i < data.errors.length; ++i ){
  50. if(data.errors[i].value!='')
  51. $("#"+data.errors[i].name).next().html('<span>'+data.errors[i].value+'</span>').fadeIn();
  52. }
  53. }
  54. },
  55. error : function(data,textStatus){}
  56. });
  57. }
  58. };

Wyłączyłem user press enter ale to nie pomogło.

Ten post edytował kemes123 8.07.2012, 18:52:01
Go to the top of the page
+Quote Post
konrados
post 8.07.2012, 19:04:21
Post #2





Grupa: Zarejestrowani
Postów: 623
Pomógł: 79
Dołączył: 16.01.2008

Ostrzeżenie: (0%)
-----


Musi pomóc. Jeśli ten skrypt jest w jakimś osobnym pliku, być może jest pobierany z cache'a przeglądarki, naciśnij Ctrl+F5 lub shift+F5 - to w większości przeglądarek robi odświeżenie bez użycia cache'a.

Ten post edytował konrados 8.07.2012, 19:04:37
Go to the top of the page
+Quote Post
kemes123
post 8.07.2012, 19:44:33
Post #3





Grupa: Zarejestrowani
Postów: 28
Pomógł: 0
Dołączył: 15.04.2010

Ostrzeżenie: (0%)
-----


ppmogło dziękówa
Go to the top of the page
+Quote Post

Reply to this topicStart new topic
1 Użytkowników czyta ten temat (1 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Wersja Lo-Fi Aktualny czas: 22.07.2025 - 21:23