1jQuery(document).ready(function() { 2 3 // Start with disabled submit button 4 jQuery(".addnewpage :submit").prop("disabled", true); 5 // Then enable it when a title is entered 6 jQuery(".addnewpage input[name='title']").keyup(function(){ 7 var $submit = jQuery(this).parent("form").find(":submit"); 8 if (jQuery(this).val().length > 0) { 9 $submit.removeAttr("disabled"); 10 } else { 11 // For when the user deletes the text 12 $submit.attr("disabled", "disabled"); 13 } 14 }).keyup(); 15 16 // Change the form's page-ID field on submit 17 jQuery(".addnewpage form").submit(function(e) { 18 19 // Build the new page ID and save in hidden form field 20 var ns = jQuery(this).find("[name='np_cat']"); 21 var title = jQuery(this).find("input[name='title']"); 22 var id = ns.val()+":"+title.val(); 23 jQuery(this).find("input[name='id']").val(id); 24 25 // Clean up the form vars, just to make the resultant URL a bit nicer 26 ns.prop("disabled", true); 27 title.prop("disabled", true); 28 29 return true; 30 }); 31 32}); 33