summaryrefslogtreecommitdiffstats
path: root/extensions/BMO/web/js
diff options
context:
space:
mode:
Diffstat (limited to 'extensions/BMO/web/js')
-rw-r--r--extensions/BMO/web/js/form_validate.js30
1 files changed, 25 insertions, 5 deletions
diff --git a/extensions/BMO/web/js/form_validate.js b/extensions/BMO/web/js/form_validate.js
index 6c8fa6f07..7e9746a5c 100644
--- a/extensions/BMO/web/js/form_validate.js
+++ b/extensions/BMO/web/js/form_validate.js
@@ -1,9 +1,16 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this file,
+ * You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This Source Code Form is "Incompatible With Secondary Licenses", as
+ * defined by the Mozilla Public License, v. 2.0. */
+
/**
- * Some Form Validation and Interaction
+ * Form Validation and Interaction
**/
-//Makes sure that there is an '@' in the address with a '.'
-//somewhere after it (and at least one character in between them
+//Makes sure that there is an '@' in the address with a '.'
+//somewhere after it (and at least one character in between them)
function isValidEmail(email) {
var at_index = email.indexOf("@");
var last_dot = email.lastIndexOf(".");
@@ -12,10 +19,23 @@ function isValidEmail(email) {
//Takes a DOM element id and makes sure that it is filled out
function isFilledOut(elem_id) {
- var str = document.getElementById(elem_id).value;
- return str.length>0 && str!="noneselected";
+ var el = document.getElementById(elem_id);
+ if (!el) {
+ console.error('Failed to find element: ' + elem_id);
+ return false;
+ }
+ var str = el.value;
+ return str.length > 0 && str != "noneselected";
}
function isChecked(elem_id) {
return document.getElementById(elem_id).checked;
}
+
+function isOneChecked(form_nodelist) {
+ for (var i = 0, il = form_nodelist.length; i < il; i++) {
+ if (form_nodelist[i].checked)
+ return true;
+ }
+ return false;
+}