1 $("#user-setup-modal-window").html("<%= escape_javascript(render partial: 'setup_popup') %>");
3 // disable the submit button on load
4 var $input = $('input:text'),
5 $register = $('#register');
7 var email_disabled = document.forms["setup_form"]["email"].disabled;
8 var email_value = document.forms["setup_form"]["email"].value;
9 var prefix_value = document.forms["setup_form"]["openid_prefix"].value;
10 if ((email_disabled == false) && (email_value == null || email_value == "" ||
11 prefix_value == null || prefix_value == "")) {
12 $register.prop('disabled', true);
15 // capture events to enable submit button when applicable
16 $input.on('keyup paste mouseleave', function() {
19 var email_disabled = document.forms["setup_form"]["email"].disabled;
20 var email_value = document.forms["setup_form"]["email"].value;
21 var prefix_value = document.forms["setup_form"]["openid_prefix"].value;
23 var emailRegExp = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;
24 var validEmail = false;
26 if (emailRegExp.test(email_value )) {
30 if ((email_disabled == false) && (!validEmail || email_value == null ||
31 email_value == "" || prefix_value == null || prefix_value == "")){
35 $register.prop('disabled', trigger);
38 // reset form input fields, for the next time around
39 function reset_form() {
41 $('#openid_prefix').val("");
42 $('#repo_name').val("");