How To Prevent Submit Form On Enter Key Except Textarea In JQuery?
Có thể bạn quan tâm
How to prevent submit form on enter key except textarea in JQuery?
In this post we will give you information about How to prevent submit form on enter key except textarea in JQuery?. Hear we will give you detail about How to prevent submit form on enter key except textarea in JQuery?And how to use it also give you demo for it if it is necessary.
In this post, i will show you how to prevent form submitting on enter key with except textarea using javascript code. You can simply do this on your php, laravel, codeigniter, asp.ent etc project.
See also How to get gravatar image from email using Jquery?In somecases, we require to disable form submit on press enter key on text box that way user must need to press submit button. We can do it simply but if we have to also textarea on that form that it can be cause issue because textarea should accept enter key and goes new line. However, we can also solve this issue by jquery code. So first let’s see bellow few lines code for prevent form submit on enter.
JQuery Code:
$(document).ready(function() {
$(window).keydown(function(event){
if((event.keyCode == 13) && ($(event.target)[0]!=$("textarea")[0])) {
event.preventDefault();
return false;
}
});
});
As above, you can see simply we can use in your jquery. I also added full example of this code. So if you don’t know how it should work then you can see bellow full example.
index.html
Also see:Ajax Image Upload using PHP and jQuery Example from scratch<!DOCTYPE html>
<html>
<head>
<title>JQuery prevent to enter to submit except Textarea</title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.js"></script>
</head>
<body>
<form method="POST">
<strong>Name:</strong>
<input type="text" name="name" placeholder="Name">
<strong>Details:</strong>
<textarea></textarea>
<button type="submit">Submit</button>
</form>
<script type="text/javascript">
$(document).ready(function() {
$(window).keydown(function(event){
if((event.keyCode == 13) && ($(event.target)[0]!=$("textarea")[0])) {
event.preventDefault();
return false;
}
});
});
</script>
</body>
</html>
I hope it can help you….
Hope this code and post will helped you for implement How to prevent submit form on enter key except textarea in JQuery?. if you need any help or any feedback give it in comment section or you have good idea about this post you can give it comment section. Your comment will help us for help you more and improve us. we will give you this type of more interesting post in featured also so, For more interesting post and code Keep reading our blogs
For More Info See :: laravel And github
Post navigation
Next Post →Leave a Comment Cancel Reply
Your email address will not be published. Required fields are marked *
Type here..Name*
Email*
Website
Save my name, email, and website in this browser for the next time I comment.
Solve Captcha*51 + = 57
Search
Search for: Search Go to mobile version We're accepting well-written guest posts and this is a great opportunity to collaborate : Contact USTừ khóa » Html Form Block Enter Submit
-
Prevent Users From Submitting A Form By Hitting Enter - Stack Overflow
-
Prevent Form Submission On Enter Key Press | Example Code
-
Prevent Form Submit On Enter Code Example - Code Grepper
-
How To Disable Form Submit On Enter Button Using JQuery
-
How To Stop The Enter Key From Submitting The Form - WPForms
-
Prevent Form Submit On Enter Is Not Working - OutSystems
-
Prevent Enter Key Submitting Forms With JQuery - Code
-
Prevent Form Submission On Enter Press In React | Bobbyhadz
-
Using JavaScript To Prevent Or Trigger Form Submission When ENTER ...
-
The Enter Key Should Submit Forms, Stop Suppressing It - TJ VanToll
-
JavaScript Disable Enter Key On Form Submission
-
Prevent Users From Accidentally Submitting A Form If Enter Key Is ...
-
Easiest Way To Disable Form Submit On Enter Pressed - YouTube
-
Html Form Prevent Submit When Hit Enter On Specific Input