disable some submit-type buttons when required data is not given

master
Andrew Dolgov 19 years ago
parent 0ceded7a46
commit 2371c520c7

@ -1823,10 +1823,12 @@
cellspacing='0' cellpadding='0'><tr> cellspacing='0' cellpadding='0'><tr>
<td> <td>
<input id=\"fadd_link\" <input id=\"fadd_link\"
onchange=\"javascript:addFeed()\" onchange=\"javascript:addFeed()\"
size=\"40\"> onkeyup=\"toggleSubmitNotEmpty(this, 'fadd_submit_btn')\"
size=\"40\">
<input type=\"submit\" class=\"button\" <input type=\"submit\" class=\"button\"
onclick=\"javascript:addFeed()\" value=\"Subscribe\">"; disabled=\"true\" id=\"fadd_submit_btn\"
onclick=\"addFeed()\" value=\"Subscribe\">";
if (ENABLE_FEED_BROWSER && !SINGLE_USER_MODE) { if (ENABLE_FEED_BROWSER && !SINGLE_USER_MODE) {
print " <input type=\"submit\" class=\"button\" print " <input type=\"submit\" class=\"button\"
@ -1835,8 +1837,7 @@
print "</td><td align='right'> print "</td><td align='right'>
<input id=\"feed_search\" size=\"20\" <input id=\"feed_search\" size=\"20\"
onchange=\"javascript:updateFeedList()\" onchange=\"javascript:updateFeedList()\" value=\"$feed_search\">
value=\"$feed_search\">
<input type=\"submit\" class=\"button\" <input type=\"submit\" class=\"button\"
onclick=\"javascript:updateFeedList()\" value=\"Search\"> onclick=\"javascript:updateFeedList()\" value=\"Search\">
</td> </td>
@ -2594,10 +2595,13 @@
} }
print "<div class=\"prefGenericAddBox\"> print "<div class=\"prefGenericAddBox\">
<input size=\"40\" id=\"ladd_expr\">&nbsp;"; <input size=\"40\"
onkeyup=\"toggleSubmitNotEmpty(this, 'label_create_btn')\"
id=\"ladd_expr\">&nbsp;";
print"<input type=\"submit\" class=\"button\" print"<input type=\"submit\" class=\"button\"
onclick=\"javascript:addLabel()\" value=\"Add label\"></div>"; disabled=\"true\" id=\"label_create_btn\"
onclick=\"javascript:addLabel()\" value=\"Create label\"></div>";
$result = db_query($link, "SELECT $result = db_query($link, "SELECT
id,sql_exp,description id,sql_exp,description
@ -2775,6 +2779,7 @@
print "<table width='100%'> print "<table width='100%'>
<tr><td>Feed URL:</td><td> <tr><td>Feed URL:</td><td>
<input onblur=\"javascript:enableHotkeys()\" <input onblur=\"javascript:enableHotkeys()\"
onkeyup=\"toggleSubmitNotEmpty(this, 'fadd_submit_btn')\"
onfocus=\"javascript:disableHotkeys()\" id=\"qafInput\"></td></tr>"; onfocus=\"javascript:disableHotkeys()\" id=\"qafInput\"></td></tr>";
if (get_pref($link, 'ENABLE_FEED_CATS')) { if (get_pref($link, 'ENABLE_FEED_CATS')) {
@ -2801,11 +2806,13 @@
print "</td></tr>"; print "</td></tr>";
} }
print "<tr><td colspan='2' align='right'><input class=\"button\" print "<tr><td colspan='2' align='right'>
type=\"submit\" onclick=\"javascript:qafAdd()\" value=\"Subscribe\"> <input class=\"button\"
<input class=\"button\" id=\"fadd_submit_btn\" disabled=\"true\"
type=\"submit\" onclick=\"javascript:closeInfoBox()\" type=\"submit\" onclick=\"javascript:qafAdd()\" value=\"Subscribe\">
value=\"Cancel\"></td></tr></table>"; <input class=\"button\"
type=\"submit\" onclick=\"javascript:closeInfoBox()\"
value=\"Cancel\"></td></tr></table>";
} }
if ($id == "quickDelFeed") { if ($id == "quickDelFeed") {
@ -2842,8 +2849,10 @@
print "<table width='100%'><tr><td>Search:</td><td>"; print "<table width='100%'><tr><td>Search:</td><td>";
print "<input id=\"searchbox\" class=\"extSearch\" print "<input id=\"searchbox\" class=\"extSearch\"
onblur=\"javascript:enableHotkeys()\" onfocus=\"javascript:disableHotkeys()\" onblur=\"javascript:enableHotkeys()\"
onchange=\"javascript:search()\"> onfocus=\"javascript:disableHotkeys()\"
onkeyup=\"toggleSubmitNotEmpty(this, 'search_submit_btn')\"
onchange=\"javascript:search()\">
</td></tr><tr><td>Where:</td><td> </td></tr><tr><td>Where:</td><td>
<select id=\"searchmodebox\"> <select id=\"searchmodebox\">
<option selected>All feeds</option>"; <option selected>All feeds</option>";
@ -2862,7 +2871,9 @@
<tr><td colspan='2' align='right'> <tr><td colspan='2' align='right'>
<input type=\"submit\" <input type=\"submit\"
class=\"button\" onclick=\"javascript:search()\" value=\"Search\"> class=\"button\" onclick=\"javascript:search()\"
id=\"search_submit_btn\" disabled=\"true\"
value=\"Search\">
<input class=\"button\" <input class=\"button\"
type=\"submit\" onclick=\"javascript:closeInfoBox()\" type=\"submit\" onclick=\"javascript:closeInfoBox()\"
value=\"Cancel\"></td></tr></table>"; value=\"Cancel\"></td></tr></table>";
@ -2885,7 +2896,9 @@
print "<table width='100%'>"; print "<table width='100%'>";
print "<tr><td>Match:</td><td><input id=\"fadd_regexp\" size=\"30\">&nbsp;"; print "<tr><td>Match:</td>
<td><input onkeyup=\"toggleSubmitNotEmpty(this, 'infobox_submit')\"
id=\"fadd_regexp\" size=\"30\">&nbsp;";
print_select("fadd_match", "Title", $filter_types); print_select("fadd_match", "Title", $filter_types);
@ -2928,8 +2941,9 @@
print "</td></tr><tr><td colspan=\"2\" align=\"right\">"; print "</td></tr><tr><td colspan=\"2\" align=\"right\">";
print "<input type=\"submit\" print "<input type=\"submit\"
id=\"infobox_submit\"
class=\"button\" onclick=\"javascript:qaddFilter()\" class=\"button\" onclick=\"javascript:qaddFilter()\"
value=\"Create\"> "; disabled=\"true\" value=\"Create\"> ";
print "<input class=\"button\" print "<input class=\"button\"
type=\"submit\" onclick=\"javascript:closeInfoBox()\" type=\"submit\" onclick=\"javascript:closeInfoBox()\"
@ -3445,10 +3459,13 @@
} }
print "<div class=\"prefGenericAddBox\"> print "<div class=\"prefGenericAddBox\">
<input id=\"uadd_box\" onchange=\"javascript:addUser()\" size=\"40\">&nbsp;"; <input id=\"uadd_box\"
onkeyup=\"toggleSubmitNotEmpty(this, 'user_add_btn')\"
onchange=\"javascript:addUser()\" size=\"40\">&nbsp;";
print"<input type=\"submit\" class=\"button\" print"<input type=\"submit\" class=\"button\"
onclick=\"javascript:addUser()\" value=\"Add user\"></div>"; id=\"user_add_btn\" disabled=\"true\"
onclick=\"javascript:addUser()\" value=\"Create user\"></div>";
$result = db_query($link, "SELECT $result = db_query($link, "SELECT
id,login,access_level,email, id,login,access_level,email,

@ -947,6 +947,7 @@ function displayDlg(id, param) {
xmlhttp.send(null); xmlhttp.send(null);
disableHotkeys(); disableHotkeys();
} }
function infobox_submit_callback() { 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);
}
}

@ -282,6 +282,9 @@ function addFeed() {
if (link.value.length == 0) { if (link.value.length == 0) {
alert("Error: No feed URL given."); alert("Error: No feed URL given.");
} else if (link.value.match("http://") == null &&
link.value.match("https://") == null) {
alert("Error: Invalid feed URL.");
} else { } else {
notify("Adding feed..."); notify("Adding feed...");

@ -535,9 +535,14 @@ function qafAdd() {
if (link.value.length == 0) { if (link.value.length == 0) {
alert("Error: No feed URL given."); alert("Error: No feed URL given.");
} else if (link.value.match("http://") == null &&
link.value.match("https://") == null) {
alert("Error: Invalid feed URL.");
} else { } else {
notify("Adding feed..."); notify("Adding feed...");
closeInfoBox();
var cat = document.getElementById("qafCat"); var cat = document.getElementById("qafCat");
var cat_id = ""; var cat_id = "";

Loading…
Cancel
Save