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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.