Javascript.RU

Создать новую тему Ответ
 
Опции темы Искать в теме
  #1 (permalink)  
Старый 30.01.2014, 17:23
Кандидат Javascript-наук
Отправить личное сообщение для soltx Посмотреть профиль Найти все сообщения от soltx
 
Регистрация: 19.05.2013
Сообщений: 144

Сброс формы jquery reset
Здравствуйте буду признателен за подсказку есть скрипт формы отправки ajax jquery

$(document).ready(function() {
	
	//if submit button is clicked
	$('#form4').submit(function () {		
		
		//Get the data from all the fields
		var name4 = $('input[name=name4]');
		
		var tel4 = $('input[name=tel4]');
		var email4 = $('input[name=email4]');
	

		//Simple validation to make sure user entered something
		//If error found, add hightlight class to the text field
		if (name4.val()=='') {
			name4.addClass('hightlight');
			return false;
		} else name4.removeClass('hightlight');
		
		if (tel4.val()=='') {
			tel4.addClass('hightlight');
			return false;
		} else tel4.removeClass('hightlight');
		
		if (email4.val()=='') {
			email4.addClass('hightlight');
			return false;
		} else email4.removeClass('hightlight');
		
		
		
		//organize the data properly
		var data = 'name4=' + name4.val()  + '&tel4=' + 
		tel4.val()+ '&email4=' + email4.val();
		
		//disabled all the text fields
	
		
		//show the loading sign
		$('.loading4').show();
		
		//start the ajax
		$.ajax({
			//this is the php file that processes the data and send mail
			url: "process4.php",	
			
			//GET method is used
			type: "GET",

			//pass the data			
			data: data,		
			
			//Do not cache the page
			cache: false,
			
			//success
			success: function (html) {				
				//if process.php returned 1/true (send mail success)
				if (html==1) {					
					//hide the form
							
				
					//show the success message
					
					
					
					

						$('.loading4').fadeOut('slow');
                     
					$('.done4').fadeIn('slow');
					$('form').fadeOut('slow');
					$('form').fadeIn('slow');
					
					
				//if process.php returned 0/false (send mail failed)
				} else alert('Sorry, unexpected error. Please try again later.');				
			}		
		});
		
		//cancel the submit button default behaviours
		return false;
	});	
});



как сбросить форму?

jQuery('form')[0].reset();




про бывал
$('form')[0].reset.fadeIn('slow');
не вышло


выходит так
$('form').fadeOut('slow');//исчезает
		  $('form').fadeIn('slow');//появляется но форма не сброшена

Последний раз редактировалось soltx, 30.01.2014 в 17:26.
Ответить с цитированием
  #2 (permalink)  
Старый 30.01.2014, 18:50
Аватар для ksa
ksa ksa вне форума
CacheVar
Отправить личное сообщение для ksa Посмотреть профиль Найти все сообщения от ksa
 
Регистрация: 19.08.2010
Сообщений: 14,123

Сообщение от soltx
как сбросить форму?
jQuery('form')[0].reset();
Нужно выйти на ДОМ-элемент

jQuery('form').get(0).reset();

http://jquery-docs.ru/Core/get/#index
Ответить с цитированием
  #3 (permalink)  
Старый 30.01.2014, 19:03
Аватар для рони
Профессор
Отправить личное сообщение для рони Посмотреть профиль Найти все сообщения от рони
 
Регистрация: 27.05.2010
Сообщений: 33,072

ksa,
так на всякий случай Form reset fadein
Ответить с цитированием
  #4 (permalink)  
Старый 31.01.2014, 21:05
Кандидат Javascript-наук
Отправить личное сообщение для soltx Посмотреть профиль Найти все сообщения от soltx
 
Регистрация: 19.05.2013
Сообщений: 144

ksa спс получилось рони не смог реализовать твой пример и донести что я хотел (причина полный 0 нужно было готовое решение) извините за две темы
Ответить с цитированием
Ответ



Опции темы Искать в теме
Искать в теме:

Расширенный поиск


Похожие темы
Тема Автор Раздел Ответов Последнее сообщение
удаление формы на jquery gamesoneve jQuery 1 13.09.2012 21:14
JQuery, проверка формы Dafina jQuery 1 04.03.2012 23:01
jQuery Form Plugin не знаю id формы! Apostol-Aristotel jQuery 0 20.01.2012 20:29
нежелательная отправка формы в jQuery UI autocomplete combobox konst56 jQuery 0 18.12.2010 11:28
Как отключить submit формы в jQuery? khusamov Общие вопросы Javascript 2 08.07.2009 00:54