diff options
Diffstat (limited to 'public/js/form-validators')
-rw-r--r-- | public/js/form-validators/accountValidator.js | 80 | ||||
-rw-r--r-- | public/js/form-validators/emailValidator.js | 39 | ||||
-rw-r--r-- | public/js/form-validators/loginValidator.js | 29 | ||||
-rw-r--r-- | public/js/form-validators/resetValidator.js | 37 |
4 files changed, 0 insertions, 185 deletions
diff --git a/public/js/form-validators/accountValidator.js b/public/js/form-validators/accountValidator.js deleted file mode 100644 index 6de2dfc..0000000 --- a/public/js/form-validators/accountValidator.js +++ /dev/null @@ -1,80 +0,0 @@ - -function AccountValidator(){ - -// build array maps of the form inputs & control groups // - - this.formFields = [$('#name-tf'), $('#email-tf'), $('#user-tf'), $('#pass-tf')]; - this.controlGroups = [$('#name-cg'), $('#email-cg'), $('#user-cg'), $('#pass-cg')]; - -// bind the form-error modal window to this controller to display any errors // - - this.alert = $('.modal-form-errors'); - this.alert.modal({ show : false, keyboard : true, backdrop : true}); - - this.validateName = function(s) - { - return s.length >= 3; - } - - this.validatePassword = function(s) - { - // if user is logged in and hasn't changed their password, return ok - if ($('#userId').val() && s===''){ - return true; - } else{ - return s.length >= 6; - } - } - - this.validateEmail = function(e) - { - var re = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/; - return re.test(e); - } - - this.showErrors = function(a) - { - $('.modal-form-errors .modal-body p').text('Please correct the following problems :'); - var ul = $('.modal-form-errors .modal-body ul'); - ul.empty(); - for (var i=0; i < a.length; i++) ul.append('<li>'+a[i]+'</li>'); - this.alert.modal('show'); - } - -} - -AccountValidator.prototype.showInvalidEmail = function() -{ - this.controlGroups[1].addClass('error'); - this.showErrors(['That email address is already in use.']); -} - -AccountValidator.prototype.showInvalidUserName = function() -{ - this.controlGroups[2].addClass('error'); - this.showErrors(['That username is already in use.']); -} - -AccountValidator.prototype.validateForm = function() -{ - var e = []; - for (var i=0; i < this.controlGroups.length; i++) this.controlGroups[i].removeClass('error'); - if (this.validateName(this.formFields[0].val()) == false) { - this.controlGroups[0].addClass('error'); e.push('Please Enter Your Name'); - } - if (this.validateEmail(this.formFields[1].val()) == false) { - this.controlGroups[1].addClass('error'); e.push('Please Enter A Valid Email'); - } - if (this.validateName(this.formFields[2].val()) == false) { - this.controlGroups[2].addClass('error'); - e.push('Please Choose A Username'); - } - if (this.validatePassword(this.formFields[3].val()) == false) { - this.controlGroups[3].addClass('error'); - e.push('Password Should Be At Least 6 Characters'); - } - if (e.length) this.showErrors(e); - return e.length === 0; -} - -
\ No newline at end of file diff --git a/public/js/form-validators/emailValidator.js b/public/js/form-validators/emailValidator.js deleted file mode 100644 index 5a87c04..0000000 --- a/public/js/form-validators/emailValidator.js +++ /dev/null @@ -1,39 +0,0 @@ - -function EmailValidator(){ - -// bind this to _local for anonymous functions // - - var _local = this; - -// modal window to allow users to request credentials by email // - _local.retrievePassword = $('#get-credentials'); - _local.retrievePassword.modal({ show : false, keyboard : true, backdrop : true }); - _local.retrievePasswordAlert = $('#get-credentials .alert'); - _local.retrievePassword.on('show', function(){ $('#get-credentials-form').resetForm(); _local.retrievePasswordAlert.hide();}); - -} - -EmailValidator.prototype.validateEmail = function(e) -{ - var re = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/; - return re.test(e); -} - -EmailValidator.prototype.showEmailAlert = function(m) -{ - this.retrievePasswordAlert.attr('class', 'alert alert-error'); - this.retrievePasswordAlert.html(m); - this.retrievePasswordAlert.show(); -} - -EmailValidator.prototype.hideEmailAlert = function() -{ - this.retrievePasswordAlert.hide(); -} - -EmailValidator.prototype.showEmailSuccess = function(m) -{ - this.retrievePasswordAlert.attr('class', 'alert alert-success'); - this.retrievePasswordAlert.html(m); - this.retrievePasswordAlert.fadeIn(500); -}
\ No newline at end of file diff --git a/public/js/form-validators/loginValidator.js b/public/js/form-validators/loginValidator.js deleted file mode 100644 index 066e822..0000000 --- a/public/js/form-validators/loginValidator.js +++ /dev/null @@ -1,29 +0,0 @@ - -function LoginValidator(){ - -// bind a simple alert window to this controller to display any errors // - - this.loginErrors = $('.modal-alert'); - this.loginErrors.modal({ show : false, keyboard : true, backdrop : true }); - - this.showLoginError = function(t, m) - { - $('.modal-alert .modal-header h3').text(t); - $('.modal-alert .modal-body p').text(m); - this.loginErrors.modal('show'); - } - -} - -LoginValidator.prototype.validateForm = function() -{ - if ($('#user-tf').val() == ''){ - this.showLoginError('Whoops!', 'Please enter a valid username'); - return false; - } else if ($('#pass-tf').val() == ''){ - this.showLoginError('Whoops!', 'Please enter a valid password'); - return false; - } else{ - return true; - } -}
\ No newline at end of file diff --git a/public/js/form-validators/resetValidator.js b/public/js/form-validators/resetValidator.js deleted file mode 100644 index 71c8792..0000000 --- a/public/js/form-validators/resetValidator.js +++ /dev/null @@ -1,37 +0,0 @@ - -function ResetValidator(){ - -// modal window to allow users to reset their password // - this.setPassword = $('#set-password'); - this.setPassword.modal({ show : false, keyboard : false, backdrop : 'static' }); - this.setPasswordAlert = $('#set-password .alert'); -} - -ResetValidator.prototype.validatePassword = function(s) -{ - if (s.length >= 6){ - return true; - } else{ - this.showAlert('Password Should Be At Least 6 Characters'); - return false; - } -} - -ResetValidator.prototype.showAlert = function(m) -{ - this.setPasswordAlert.attr('class', 'alert alert-error'); - this.setPasswordAlert.html(m); - this.setPasswordAlert.show(); -} - -ResetValidator.prototype.hideAlert = function() -{ - this.setPasswordAlert.hide(); -} - -ResetValidator.prototype.showSuccess = function(m) -{ - this.setPasswordAlert.attr('class', 'alert alert-success'); - this.setPasswordAlert.html(m); - this.setPasswordAlert.fadeIn(500); -}
\ No newline at end of file |