From d2177762018b6105abe902471e18c9cfa3fc8b0a Mon Sep 17 00:00:00 2001 From: Jeff Becker Date: Sun, 1 May 2016 10:31:14 -0400 Subject: [PATCH] try using onsubmit for reply box form --- contrib/js/backlink.js | 12 +++++++----- contrib/static/nntpchan.js | 7 ++++--- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/contrib/js/backlink.js b/contrib/js/backlink.js index b64f212..2db0160 100644 --- a/contrib/js/backlink.js +++ b/contrib/js/backlink.js @@ -40,8 +40,6 @@ function DynReply(existingElem) { this.form = this.elem.querySelector("form"); this._error = document.getElementById("postform_msg"); this.url = this.form.action + "?t=json"; - var e = document.getElementById("postform_submit"); - e.setAttribute("type", "button"); return; } @@ -83,7 +81,7 @@ function DynReply(existingElem) { var submit = document.createElement("input"); submit.setAttribute("value", "reply"); submit.setAttribute("class", "button"); - submit.setAttribute("type", "button"); + submit.setAttribute("type", "submit"); submit.setAttribute("id", "postform_submit"); table_insert_row(tbody, document.createTextNode("Subject"), [elem, submit]); @@ -121,7 +119,7 @@ function DynReply(existingElem) { elem = document.createElement("input"); elem.name = "captcha"; elem.autocomplete = "off"; - table_insert_row(tbody, document.createTextNode("Name"), [elem]) + table_insert_row(tbody, document.createTextNode("Solution"), [elem]) table.appendChild(tbody); this.form.appendChild(table); @@ -349,7 +347,7 @@ function init(prefix) { // add replyto post handlers e = document.getElementById("postform_submit"); - e.onclick = function() { + var postit = function() { var f = document.querySelector("form"); // do ajax request to post data var r = getReplyTo(); @@ -367,5 +365,9 @@ function init(prefix) { }); r.showMessage("posting... "); } + e.onclick = postit; + var f = document.querySelector("form"); + f.onsubmit = postit; + } diff --git a/contrib/static/nntpchan.js b/contrib/static/nntpchan.js index 0d89d71..b5b7a47 100644 --- a/contrib/static/nntpchan.js +++ b/contrib/static/nntpchan.js @@ -15,9 +15,9 @@ var dynreply;function getReplyTo(){if(!dynreply){var e=document.getElementById(" return dynreply;} function table_insert_row(table,header,items){var tr=document.createElement("tr");var th=document.createElement("th");th.appendChild(header);tr.appendChild(th);for(var idx=0;idx