Second option is perfect. Thanks for the information. On May 5, 2017 18:25, "Jim S" <ato.st...@gmail.com> wrote:
Can you try the following: 1. <input type="submit" value"Send" /> or 2. {{=form.custom.submit}} and then control your text and classes through your controller. -Jim On Friday, May 5, 2017 at 10:17:06 AM UTC-5, Maurice Waka wrote: > Without js, form still only submitted by hitting enter. I'll check this > other link. Regards > > On May 5, 2017 18:07, "Jim S" <ato....@gmail.com> wrote: > >> Can you strip out all of your javascript and confirm that the standard >> form submission is working with Kiran's solution? >> >> Then, put your javascript back in and watch the javascript console during >> execution to see where you're getting hung up? >> >> Then for your second issue, have you looked at javascript/jquery >> solutions? Such as http://stackoverflow.com/qu >> estions/895171/prevent-users-from-submitting-a-form-by-hitting-enter >> >> -Jim >> >> On Friday, May 5, 2017 at 9:56:28 AM UTC-5, Maurice Waka wrote: >>> >>> Still no change. How about the preventing page refreshing >>> >>> On May 5, 2017 10:06, "Kiran Subbaraman" <subbaram...@gmail.com> wrote: >>> >>>> The `{{=form.custom.end}}` has to be after the submit button. >>>> http://web2py.com/books/default/chapter/29/07/forms-and- >>>> validators#Custom-forms >>>> >>>> ________________________________________ >>>> Kiran Subbaramanhttp://subbaraman.wordpress.com/about/ >>>> >>>> On Fri, 05-05-2017 11:15 AM, Maurice Waka wrote: >>>> >>>> I have a web2py app, with two problems: >>>> >>>> 1. I can submit the customized form with pressing 'Enter' but when >>>> clicking the button, I get an error. >>>> >>>> 2. when pressing 'Enter', the form is submitted but the page is >>>> refreshed immediately. How can i stop that? >>>> >>>> Here is the code; This does not work >>>> >>>> <div class="message_input_wrapper"> >>>> {{=form.custom.begin}} >>>> <input name="body" class="message_input" placeholder="Type your >>>> message here..."/> >>>> {{=form.custom.end}} </div><button type="submit" >>>> class="send_message">Send</button> >>>> >>>> This does not work either: >>>> >>>> <div class="message_input_wrapper"> >>>> {{=form.custom.begin}} >>>> <input name="body" class="message_input" placeholder="Type your >>>> message here..."/> >>>> {{=form.custom.end}} >>>> <button type="submit" class="send_message">Send</button> >>>> </div> >>>> >>>> This is the js code: >>>> >>>> (function () { >>>> var Message;Message = function (arg) { >>>> this.text = arg.text, this.message_side = arg.message_side; >>>> this.draw = function (_this) { >>>> return function () { >>>> var $message; >>>> $message = $($('.message_template').clone().html()); >>>> >>>> $message.addClass(_this.message_side).find('.text').html(_this.text); >>>> $('.messages').append($message); >>>> return setTimeout(function () { >>>> return $message.addClass('appeared'); >>>> }, 0); >>>> }; >>>> }(this); >>>> return this;}; >>>> $(function () { >>>> var getMessageText, message_side, sendMessage; >>>> message_side = 'right'; >>>> getMessageText = function () { >>>> var $message_input; >>>> $message_input = $('.message_input'); >>>> return $message_input.val(); >>>> }; >>>> sendMessage = function (text) { >>>> var $messages, message; >>>> if (text.trim() === '') { >>>> return; >>>> } >>>> $('.message_input').val(''); >>>> $messages = $('.messages'); >>>> message_side = message_side === 'left' ? 'right' : 'left'; >>>> message = new Message({ >>>> text: text, >>>> message_side: message_side >>>> }); >>>> message.draw(); >>>> return $messages.animate({ scrollTop: >>>> $messages.prop('scrollHeight') }, 300); >>>> }; >>>> $('.send_message').click(function (e) { >>>> return sendMessage(getMessageText()); >>>> }); >>>> $('.message_input').keyup(function (e) { >>>> if (e.which === 13) { >>>> return sendMessage(getMessageText()); >>>> } >>>> }); >>>> >>>> >>>> >>>> -- >>>> Resources: >>>> - http://web2py.com >>>> - http://web2py.com/book (Documentation) >>>> - http://github.com/web2py/web2py (Source code) >>>> - https://code.google.com/p/web2py/issues/list (Report Issues) >>>> --- >>>> You received this message because you are subscribed to the Google >>>> Groups "web2py-users" group. >>>> To unsubscribe from this group and stop receiving emails from it, send >>>> an email to web2py+un...@googlegroups.com. >>>> For more options, visit https://groups.google.com/d/optout. >>>> >>>> >>>> -- >>>> Resources: >>>> - http://web2py.com >>>> - http://web2py.com/book (Documentation) >>>> - http://github.com/web2py/web2py (Source code) >>>> - https://code.google.com/p/web2py/issues/list (Report Issues) >>>> --- >>>> You received this message because you are subscribed to a topic in the >>>> Google Groups "web2py-users" group. >>>> To unsubscribe from this topic, visit https://groups.google.com/d/to >>>> pic/web2py/oEjq7ACIqwI/unsubscribe. >>>> To unsubscribe from this group and all its topics, send an email to >>>> web2py+un...@googlegroups.com. >>>> For more options, visit https://groups.google.com/d/optout. >>>> >>> -- >> Resources: >> - http://web2py.com >> - http://web2py.com/book (Documentation) >> - http://github.com/web2py/web2py (Source code) >> - https://code.google.com/p/web2py/issues/list (Report Issues) >> --- >> You received this message because you are subscribed to a topic in the >> Google Groups "web2py-users" group. >> To unsubscribe from this topic, visit https://groups.google.com/d/to >> pic/web2py/oEjq7ACIqwI/unsubscribe. >> To unsubscribe from this group and all its topics, send an email to >> web2py+un...@googlegroups.com. >> For more options, visit https://groups.google.com/d/optout. >> > -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to a topic in the Google Groups "web2py-users" group. To unsubscribe from this topic, visit https://groups.google.com/d/ topic/web2py/oEjq7ACIqwI/unsubscribe. To unsubscribe from this group and all its topics, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout. -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.