allura
修訂 | a0d1af6c8633494b5063f5f66f64b3306aad8ef6 (tree) |
---|---|
時間 | 2012-05-22 11:01:29 |
作者 | Cory Johns <johnsca@geek...> |
Commiter | Tim Van Steenburgh |
[#3592] Prevent submitting new project form if errors
Signed-off-by: Cory Johns <johnsca@geek.net>
@@ -288,10 +288,10 @@ class NeighborhoodAddProjectForm(ForgeForm): | ||
288 | 288 | yield ew.JSScript(''' |
289 | 289 | $(function(){ |
290 | 290 | var $scms = $('input[type=checkbox].scm'); |
291 | - var $name_avail_message = $('#name_availability'); | |
292 | 291 | var $name_input = $('input[name="%(project_name)s"]'); |
293 | 292 | var $unixname_input = $('input[name="%(project_unixname)s"]'); |
294 | 293 | var $url_fragment = $('#url_fragment'); |
294 | + var $form = $name_input.closest('form'); | |
295 | 295 | var delay = (function(){ |
296 | 296 | var timers = {}; |
297 | 297 | return function(callback, ms){ |
@@ -317,6 +317,14 @@ class NeighborhoodAddProjectForm(ForgeForm): | ||
317 | 317 | $error_field.text(message).toggle(!!message); |
318 | 318 | update_icon($input); |
319 | 319 | }; |
320 | + $form.submit(function(e) { | |
321 | + var has_errors = $name_input.add($unixname_input).nextAll('.error').is(':visible'); | |
322 | + if (has_errors || $name_input.val() == '' || $unixname_input.val() == '') { | |
323 | + e.preventDefault(); | |
324 | + alert('You must resolve the issues with the project name.'); | |
325 | + return false; | |
326 | + } | |
327 | + }); | |
320 | 328 | $scms.change(function(){ |
321 | 329 | if ( $(this).attr('checked') ) { |
322 | 330 | var on = this; |