JS Implementation Ctrl+enter Submit Comment code

Source: Internet
Author: User

Example 1

The code is as follows Copy Code

<script language=javascript>
ie = (document.all)? True:false
if (IE) {
function Ctlent (eventobject) {if (Event.ctrlkey && window.event.keycode==13) {this.document.form1.submit ();}}
}
</script>

<form action= "add.php" Method=post name=form1>
<textarea cols=95 name=content rows=12 wrap=virtual onkeydown=ctlent () >
Ctrl+enter Submit Content Information
</textarea>
<input type=submit value= "Submit" name=submit>
</form>


Wordpress–ctrl+enter

Control Panel → appearance → edit →comment.php, found in this area:

The code is as follows Copy Code

<textarea name= "comment" id= "comment" cols= "70%" rows= "Ten" tabindex= "4" ></textarea>

Add this passage:

Onkeydown= ' if (event.ctrlkey&&event.keycode==13) {document.getElementById (' Submit '). Click (); return false} ;"

The last is this:


<textarea name= "comment" id= "comment" cols= "70%" rows= "" tabindex= "4" onkeydown= "if (event.ctrlkey&& event.keycode==13) {document.getElementById (' Submit '). Click (); return false}; " ></textarea>

Can.

Emlog Implementation Ctrl+enter Submit comments

Insert code behind the button-related code in the template file module.php

The code is as follows Copy Code

<script>
$ (function () {
$ (document). KeyPress (function (e) {
if (e.ctrlkey && E.which = | | e.which = 10) {
$ ("#commentform"). Submit ();
else if (e.shiftkey && e.which==13 | | e.which = = 10) {
$ ("#commentform"). Submit ();
}
})
});
</script>

Dedecms Add Ctrl+enter Submit Comment

In the template article_article.html template
Modify Top
Add the following JS code:

The code is as follows Copy Code

<script type= "Text/javascript" >
function Tijiao ()
{
var ev = NULL;
if (window.event) {
EV = window.event;
}
if (EV!= null&&ev.ctrlkey&& ev.keycode ==13)
{
Checksubmit ();
}
}
</script>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.