Fixed issue with form validation that was resulting in a double form submission.
This commit is contained in:
parent
ce71b0b1b8
commit
435194b060
3 changed files with 11 additions and 7 deletions
6
js/combined.min.js
vendored
6
js/combined.min.js
vendored
File diff suppressed because one or more lines are too long
|
@ -13,7 +13,7 @@ $(document).ready(function()
|
|||
var form = $(this).parents('form').get();
|
||||
|
||||
// Checks that it's valid
|
||||
if (typeof form.valid == 'undefined' || form.valid() == true)
|
||||
if (typeof $(form).valid == 'undefined' || $(form).valid() == true)
|
||||
{
|
||||
// Sets the buttons, inputs and textareas to READONLY
|
||||
$('button, input, textarea', form).attr('readonly', 'readonly');
|
||||
|
@ -100,6 +100,10 @@ $(document).ready(function()
|
|||
});
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
// Forces forms to return false on submit
|
||||
|
|
6
js/core.min.js
vendored
6
js/core.min.js
vendored
|
@ -1,5 +1,5 @@
|
|||
$(document).ready(function(){jQuery().validate&&$("form").validate();$("form.ajax input[type=submit],form.ajax button.submit").live("click",function(){var a=$(this).parents("form").get();if(typeof a.valid=="undefined"||a.valid()==true){$("button, input, textarea",a).attr("readonly","readonly");document.body.style.cursor="wait";if(typeof CKEDITOR!="undefined")if(typeof CKEDITOR.instances!="undefined")for(var d in CKEDITOR.instances){var c=CKEDITOR.instances[d].getData();c!=""&&$("#"+d).val(c)}d=$(a).attr("method")==
|
||||
""?"GET":$(a).attr("method");c=$(a).attr("action");c==""?injectMessage(a,"Form element lacks action attribute","error"):$.ajax({type:d,url:c,data:$(a).serialize(),dataType:"json",success:function(b){if(b.status!="success"&&typeof b.message!="undefined"){injectMessage(a,b.message,"error");$("button",a).show()}else if(b.status=="success"){$("input[type=text]",a).val("");$("select",a).val("");$("textarea",a).val("");typeof b.message!="undefined"&&injectMessage(a,b.message,"message");if(typeof b.url!=
|
||||
"undefined")parent.location.href=b.url;typeof b.callback!="undefined"&&window[b.callback](b)}else injectMessage(a,b,"error");$("button, input, textarea",a).attr("readonly","");document.body.style.cursor="default"},error:function(){}})}});$("form.ajax").submit(function(){return false});$("table tr:even td").addClass("even");$("table tr:odd td").addClass("odd")});
|
||||
$(document).ready(function(){jQuery().validate&&$("form").validate();$("form.ajax input[type=submit],form.ajax button.submit").live("click",function(){var a=$(this).parents("form").get();if(typeof $(a).valid=="undefined"||$(a).valid()==true){$("button, input, textarea",a).attr("readonly","readonly");document.body.style.cursor="wait";if(typeof CKEDITOR!="undefined")if(typeof CKEDITOR.instances!="undefined")for(var d in CKEDITOR.instances){var c=CKEDITOR.instances[d].getData();c!=""&&$("#"+d).val(c)}d=
|
||||
$(a).attr("method")==""?"GET":$(a).attr("method");c=$(a).attr("action");c==""?injectMessage(a,"Form element lacks action attribute","error"):$.ajax({type:d,url:c,data:$(a).serialize(),dataType:"json",success:function(b){if(b.status!="success"&&typeof b.message!="undefined"){injectMessage(a,b.message,"error");$("button",a).show()}else if(b.status=="success"){$("input[type=text]",a).val("");$("select",a).val("");$("textarea",a).val("");typeof b.message!="undefined"&&injectMessage(a,b.message,"message");
|
||||
if(typeof b.url!="undefined")parent.location.href=b.url;typeof b.callback!="undefined"&&window[b.callback](b)}else injectMessage(a,b,"error");$("button, input, textarea",a).attr("readonly","");document.body.style.cursor="default"},error:function(){}})}else return false});$("form.ajax").submit(function(){return false});$("table tr:even td").addClass("even");$("table tr:odd td").addClass("odd")});
|
||||
function injectMessage(a,d,c){if(typeof c=="undefined")c="error";switch(c){case "error":var b="#800";break;case "message":b="#080";break;default:b="#000"}c="ajax-form-"+c;b="display:none;color:"+b;$("."+c,a).remove();$(a).prepend('<div class="'+c+'" style="'+b+'" generated="true">'+d+"</div>");$("."+c,a).fadeIn()}function autoTab(a){$(a).val().length>=$(a).attr("maxlength")&&$(a).next().focus()}function disableEnterKey(a){return(window.event?window.event.keyCode:a.which)!=13}
|
||||
function truncate(a,d,c){if(a.length>d)a=c==true?'<span title="'+a+'" style="cursor:help">'+a.substring(0,d)+"...</span>":a.substring(0,d)+"...";return a};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue