Mein Code verursacht, dass ie7 diesen Fehler auslöst. 'this.0.form' ist null oder kein Objekt Es gibt eine Schaltfläche, die das Senden des Formulars auslöst, wenn darauf geklickt wird Wenn dies passiert, wird das Formular validiert, aber das Validierungs-Plugin. In anderen Browsern funktioniert das einwandfrei. In ie7 stürzt es ab und verbrennt den obigen Fehler.jquery validation 'this.0.form' ist null oder kein Objekt
$(document).ready(function(){
//form rotate to next section
window.section = 1;
function secnext()
{
var current;
var next;
var valid;
current = window.section;
//on next validate fields
//if not valid submit form to return errors and return 0
switch(current)
{
case 1:
valid = section1();
break;
case 2:
valid = section2();
break;
case 3:
valid = section3();
break;
case 4:
valid = section4();
}
if(valid == false) return 0;
//if(current == 4) next == 0;
next = current+1;
if(current == 1) $('#previous').parent().show('slow');
//hide current
$('#section'+current).hide('slide',500,function()
{
$('#section'+next).show('slide',500);});
//display next
//setTimeout(function() { $('#section'+next).slideToggle('slow');}, 300);
if(next == 4)
{
$('#next').parent().hide('slow');
$('#sendbutton').parent().parent().show('slow');
}
window.section = next;
}
$('#next').click(function()
{
//$dialog.dialog("open");
secnext();
//setTimeout(function() { $dialog.dialog("close"); }, 1500);
});
// hide section by section if all fields are valid and focus is in different section
function section1()
{
if($('input#fname').valid() &&
$('input#lname').valid() &&
$('input#email').valid() &&
$('input#homephone').valid() &&
$('select#ismilitary').valid())
{
return true;
} else {
$('form#creditapp').submit();
return false;
}
}
function section2()
{
if($('input#address').valid() &&
$('input#city').valid() &&
$('input#state').valid() &&
$('input#zip').valid() &&
$('select#dob_month').valid() &&
$('select#dob_day').valid() &&
$('select#dob_year').valid() &&
$('input#ssn').valid() &&
$('input#dlnum').valid() &&
$('input#dlst').valid())
{
return true;
} else {
$('form#creditapp').submit();
return false;
}
}
function section3()
{
if($('input#employer').valid() && $('input#workphone').valid() && $('select#employed_year').valid() && $('select#employed_month').valid()
&& $('select#paymethod').valid() && $('select#incomesrc').valid() && $('input#paychkamount').valid() && $('select#payfreq').valid()
&& $('input#nextpayday1').valid() && $('input#nextpayday2').valid())
{
return true;
} else {
$('form#creditapp').submit();
return false;
}
}
function section4()
{
if($('input#bankname').valid() && $('select#acctype').valid() && $('input#routingnum').valid() && $('input#accnum').valid())
{
return true;
} else {
$('form#creditapp').submit();
return false;
}
}
/*section1();
section2();
section3();
section4();*/
/**
* assign click handler to button
* on button click reassign focus event to section and hide button
**/
/*$('.button').click(function(index){
switch($(this).parent().parent().attr('id'))
{
case 'button1':
$('#button1').slideToggle('slow');
$('#section1').slideToggle('slow');
section1();
break;
case 'button2':
$('#button2').slideToggle('slow');
$('#section2').slideToggle('slow');
section2();
break;
case 'button3':
$('#button3').slideToggle('slow');
$('#section3').slideToggle('slow');
section3();
break;
case 'button4':
$('#button4').slideToggle('slow');
$('#section4').slideToggle('slow');
section4();
break;
}
});*/
function hidesections()
{
/*if($('input#fname').valid() && $('input#lname').valid() && $('input#email').valid() && $('input#homephone').valid() && $('select#ismilitary').valid())
{
$('#section1').hide('slow');
}
if($('input#address').valid() && $('input#city').valid() && $('input#state').valid() && $('input#zip').valid() && $('[name="bday"]').valid()
&& $('input#ssn').valid() && $('input#dlnum').valid() && $('input#dlst').valid())
{
$('#section2').hide('slow');
}
if($('input#employer').valid() && $('input#workphone').valid() && $('select#employed_years').valid() && $('select#employed_months').valid()
&& $('select#paymethod').valid() && $('select#incomesrc').valid() && $('input#paychkamount').valid() && $('select#payfreq').valid()
&& $('input#nextpayday1').valid() && $('input#nextpayday2').valid())
{
$('#section3').hide('slow');
}
if($('input#bankname').valid() && $('select#acctype').valid() && $('input#routingnum').valid() && $('input#accnum').valid())
{
$('#section4').hide('slow');
}*/
}
//save whole form
function saveform()
{
var data = '';
$('input').each(function(index) {
data += $(this).attr('name')+'='+$(this).val()+'&';
});
$('select').each(function(index) {
if($(this).attr('name') != 'employed_years' && $(this).attr('name') != 'dob_month' && $(this).attr('name') != 'dob_day')
{
switch($(this).attr('name'))
{
case 'employed_months':
value = $('select#employed_years').val() * 12
+ $('select#employed_months').val();
data += 'emplength='+value+'&';
break;
case 'dob_year':
value = $('select#dob_month').val()+'/'+$('select#dob_day').val()+'/'+$('select#dob_year').val();
data += 'bday='+value+'&';
break;
default:
data += $(this).attr('name')+'='+$(this).val()+'&';
}
}
});
$.ajax({
type: "POST",
url: "submit.php?type=form",
data: data,
success: function(msg){
//alert('Your Application has been sent');
window.location = "http://www.galleryhomestore.com/success";
}
});
} //validation $('#creditapp').validate({
/*groups: {
bday: "dob_month dob_day dob_year"
},
errorPlacement: function(error, element) {
if (element.attr("name") == "dob_month"
|| element.attr("name") == "dob_day" || element.attr("name") == "dob_year")
error.insertAfter("#dob_year");
else
error.insertAfter(element);
},*/
submitHandler: function() {
//alert('submitted');
/*
bday and years employed
*/
//if($('#dob_day').val() != 'day' && $('#dob_month').val() != 'month' && $('#dob_year').val() != 'year' && $('#employed_month').val() != 'month' && $('#employed_year').val() != 'year')
//{
$('div#form').slideToggle('slow');
$('#sending').slideToggle('slow');
saveform();
//}
}
});
Oh, es ist schlimmer als das ... das '}' über dem kommentierten Abschnitt schließt die Funktion und der 'submitHandler' schwebt in der Luft; es ist nicht Teil von 'ajax()'. Diese Art, JS zu schreiben, ist irgendwie komisch für mich, warum sind alle Funktionen in 'ready ({...})' deklariert? – Liz