diff options
author | Byron Jones <glob@mozilla.com> | 2014-09-16 06:49:50 +0200 |
---|---|---|
committer | Byron Jones <glob@mozilla.com> | 2014-09-16 06:49:50 +0200 |
commit | e1d1c642500768cafbf1f4880c9bf7abb0804e1d (patch) | |
tree | f5307bb6b2e4d47c8405fba820c210ce6c9005e4 /extensions/BMO/web | |
parent | 64808c867b1fe6ac2b8fc81d951821f602e7bea2 (diff) | |
download | bugzilla-e1d1c642500768cafbf1f4880c9bf7abb0804e1d.tar.gz bugzilla-e1d1c642500768cafbf1f4880c9bf7abb0804e1d.tar.xz |
Bug 1058615: New Custom Bugzilla Form Needed For PR Team
Diffstat (limited to 'extensions/BMO/web')
-rw-r--r-- | extensions/BMO/web/js/form_validate.js | 30 |
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; +} |