diff options
Diffstat (limited to 'bootstrap/comments/frontend/emailvalidator.js')
-rw-r--r-- | bootstrap/comments/frontend/emailvalidator.js | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/bootstrap/comments/frontend/emailvalidator.js b/bootstrap/comments/frontend/emailvalidator.js new file mode 100644 index 0000000..7e7cf85 --- /dev/null +++ b/bootstrap/comments/frontend/emailvalidator.js @@ -0,0 +1,42 @@ +// Handles display of various e-mail warnings (emailvalidator.js) +HashOver.prototype.emailValidator = function (form, subscribe, type, permalink, isReply, isEdit) +{ + if (form.email === undefined) { + return true; + } + + // Whether the e-mail form is empty + if (form.email.value === '') { + // Return true if user unchecked the subscribe checkbox + if (this.elements.get (subscribe, true).checked === false) { + return true; + } + + // If so, warn the user that they won't receive reply notifications + // if (confirm (this.locale['no-email-warning']) === false) { + // form.email.focus (); + // return false; + // } + + } else { + // If not, check if the e-mail is valid + if (this.regex.email.test (form.email.value) === false) { + // Return true if user unchecked the subscribe checkbox + if (this.elements.get (subscribe, true).checked === false) { + form.email.value = ''; + return true; + } + + // Get message from locales + var message = this.locale['invalid-email']; + + // Show the message and focus the e-mail input + this.messages.show (message, type, permalink, true, isReply, isEdit); + form.email.focus (); + + return false; + } + } + + return true; +}; |