Xtremer360 Posted September 26, 2012 Share Posted September 26, 2012 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+$/ }); }); Quote Link to comment https://forums.phpfreaks.com/topic/268833-not-running-submithandler-function/ Share on other sites More sharing options...
jazzman1 Posted September 28, 2012 Share Posted September 28, 2012 Is it a prototype, jQuery library or some mixed? Quote Link to comment https://forums.phpfreaks.com/topic/268833-not-running-submithandler-function/#findComment-1381464 Share on other sites More sharing options...
Adam Posted September 28, 2012 Share Posted September 28, 2012 It's jQuery. Can you please repost the code indented CoolAsCarlito? Quote Link to comment https://forums.phpfreaks.com/topic/268833-not-running-submithandler-function/#findComment-1381535 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.