Jump to content

Not Running Submithandler Function


Xtremer360

Recommended Posts

I have no idea but I've tried alerting everywhere in my code and can't find out why its not getting down to my submitHandler. Any ideas?

 

$(window).load(function()
{
$.validator.addMethod('regexp', function(value, element, param)
{
return this.optional(element) || value.match(param);
}, 'This is not an accepted value!');

var validatelogin = $("form").validate({
invalidHandler: function(form, validator) {
var errors = validator.numberOfInvalids();
if (errors) {
var message = errors == 1
? 'You missed 1 field. It has been highlighted.'
: 'You missed ' + errors + ' fields. They have been highlighted.';
$('.box .content').removeAlertBoxes();
$('.box .content').alertBox(message, {type: 'warning', icon: true, noMargin: false});
$('.box .content .alert').css({
width: '',
margin: '0',
borderLeft: 'none',
borderRight: 'none',
borderRadius: 0
});
} else {
$('.box .content').removeAlertBoxes();
}
},
showErrors : function(errorMap, errorList) {
this.defaultShowErrors();
var self = this;
$.each(errorList, function() {
var $input = $(this.element);
var $label = $input.parent().find('label.error').hide();
$label.addClass('red');
$label.css('width', '');
$input.trigger('labeled');
$label.fadeIn();
});
},
submitHandler: function(form)
{
var dataString = $('form').serialize();
$.ajax(
{
type: 'POST',
url: 'login/submit',
data: dataString,
dataType: 'json',
success: function(data)
{
if (data.error == 'TRUE')
{
$('.box .content').removeAlertBoxes();
$('box .content').alertBox(data.message,
{
type: 'warning',
icon: true,
noMargin: false
});
$('.box .content .alert').css(
{
width: '',
margin: '0',
borderLeft: 'none',
borderRight: 'none',
borderRadius: 0
});
}
else
{
window.location = '/cpanel/dashboard'
}
}
});
}
});

$('#login_form input[name="username"]').rules('add',
{
required: true,
minlength: 6,
maxlength: 12,
regexp: /^\w+$/
});

$('#login_form input[name="password"]').rules('add',
{
required: true,
minlength: 6,
maxlength: 12,
regexp: /^\w+$/
});
});

Link to comment
https://forums.phpfreaks.com/topic/268833-not-running-submithandler-function/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.