From 2371c520c734769f8150ddf5101052bd0973337e Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Thu, 18 May 2006 09:29:17 +0100 Subject: [PATCH] disable some submit-type buttons when required data is not given --- backend.php | 55 ++++++++++++++++++++++++++++++++++------------------ functions.js | 9 ++++++++- prefs.js | 3 +++ tt-rss.js | 7 ++++++- 4 files changed, 53 insertions(+), 21 deletions(-) diff --git a/backend.php b/backend.php index be7aba38..66d52ae9 100644 --- a/backend.php +++ b/backend.php @@ -1823,10 +1823,12 @@ cellspacing='0' cellpadding='0'> + onchange=\"javascript:addFeed()\" + onkeyup=\"toggleSubmitNotEmpty(this, 'fadd_submit_btn')\" + size=\"40\"> "; + disabled=\"true\" id=\"fadd_submit_btn\" + onclick=\"addFeed()\" value=\"Subscribe\">"; if (ENABLE_FEED_BROWSER && !SINGLE_USER_MODE) { print " + onchange=\"javascript:updateFeedList()\" value=\"$feed_search\"> @@ -2594,10 +2595,13 @@ } print "
-  "; +  "; print"
"; + disabled=\"true\" id=\"label_create_btn\" + onclick=\"javascript:addLabel()\" value=\"Create label\">"; $result = db_query($link, "SELECT id,sql_exp,description @@ -2775,6 +2779,7 @@ print ""; if (get_pref($link, 'ENABLE_FEED_CATS')) { @@ -2801,11 +2806,13 @@ print ""; } - print "
Feed URL:
-
"; + print " + + "; } if ($id == "quickDelFeed") { @@ -2842,8 +2849,10 @@ print "
Search:"; print " + onblur=\"javascript:enableHotkeys()\" + onfocus=\"javascript:disableHotkeys()\" + onkeyup=\"toggleSubmitNotEmpty(this, 'search_submit_btn')\" + onchange=\"javascript:search()\">
Where:
+ class=\"button\" onclick=\"javascript:search()\" + id=\"search_submit_btn\" disabled=\"true\" + value=\"Search\">
"; @@ -2885,7 +2896,9 @@ print ""; - print " +
Match: "; + print "
Match: "; print_select("fadd_match", "Title", $filter_types); @@ -2928,8 +2941,9 @@ print "
"; print " "; + disabled=\"true\" value=\"Create\"> "; print " -  "; +  "; print""; + id=\"user_add_btn\" disabled=\"true\" + onclick=\"javascript:addUser()\" value=\"Create user\">"; $result = db_query($link, "SELECT id,login,access_level,email, diff --git a/functions.js b/functions.js index d5ac2c08..6b064b2f 100644 --- a/functions.js +++ b/functions.js @@ -947,6 +947,7 @@ function displayDlg(id, param) { xmlhttp.send(null); disableHotkeys(); + } function infobox_submit_callback() { @@ -1009,4 +1010,10 @@ function qaddFilter() { } - +function toggleSubmitNotEmpty(e, submit_id) { + try { + document.getElementById(submit_id).disabled = (e.value == "") + } catch (e) { + exception_error("toggleSubmitNotEmpty", e); + } +} diff --git a/prefs.js b/prefs.js index 2539c3b6..8622526d 100644 --- a/prefs.js +++ b/prefs.js @@ -282,6 +282,9 @@ function addFeed() { if (link.value.length == 0) { alert("Error: No feed URL given."); + } else if (link.value.match("http://") == null && + link.value.match("https://") == null) { + alert("Error: Invalid feed URL."); } else { notify("Adding feed..."); diff --git a/tt-rss.js b/tt-rss.js index f3f496b1..82a52e94 100644 --- a/tt-rss.js +++ b/tt-rss.js @@ -535,9 +535,14 @@ function qafAdd() { if (link.value.length == 0) { alert("Error: No feed URL given."); + } else if (link.value.match("http://") == null && + link.value.match("https://") == null) { + alert("Error: Invalid feed URL."); } else { notify("Adding feed..."); - + + closeInfoBox(); + var cat = document.getElementById("qafCat"); var cat_id = ""; -- 2.39.5