jQuery validation not working on pressing enter key in Magento2.2.5?custom form validation not workingProduct validation form jqueryjQuery autocomplete select box - must press “Enter” KeyMagento 2 - jQuery validation custom error messageMagento 2 Add new field to Magento_User admin formAdding jQuery plugin to Magento 2 does not workMagento 2 - Update quantity and totals of cart page without page reload?Jquery not working properly?Can't validate Post Code on checkout pageHow to use jquery event enter key save popup
How seriously should I take size and weight limits of hand luggage?
What killed these X2 caps?
Forgetting the musical notes while performing in concert
What exploit Are these user agents trying to use?
Could the museum Saturn V's be refitted for one more flight?
Avoiding the "not like other girls" trope?
How do I gain back my faith in my PhD degree?
Why do bosons tend to occupy the same state?
How to show a landlord what we have in savings?
CAST throwing error when run in stored procedure but not when run as raw query
Intersection Puzzle
Arrow those variables!
Why no variance term in Bayesian logistic regression?
Can we compute the area of a quadrilateral with one right angle when we only know the lengths of any three sides?
How dangerous is XSS?
What reasons are there for a Capitalist to oppose a 100% inheritance tax?
How did the Super Star Destroyer Executor get destroyed exactly?
Personal Teleportation: From Rags to Riches
Is there an expression that means doing something right before you will need it rather than doing it in case you might need it?
Would Slavery Reparations be considered Bills of Attainder and hence Illegal?
What mechanic is there to disable a threat instead of killing it?
How could indestructible materials be used in power generation?
Mathematica command that allows it to read my intentions
Zip/Tar file compressed to larger size?
jQuery validation not working on pressing enter key in Magento2.2.5?
custom form validation not workingProduct validation form jqueryjQuery autocomplete select box - must press “Enter” KeyMagento 2 - jQuery validation custom error messageMagento 2 Add new field to Magento_User admin formAdding jQuery plugin to Magento 2 does not workMagento 2 - Update quantity and totals of cart page without page reload?Jquery not working properly?Can't validate Post Code on checkout pageHow to use jquery event enter key save popup
I have used jQuery validation, but it is not working on pressing enter key in Magento2.2.5?
But works on Submit button.
Refer my code.
<script src="http://ajax.aspnetcdn.com/ajax/jquery.validate/1.11.1/jquery.validate.min.js"></script>
<script type="text/javascript">
require([
'jquery'
], function($){
// jQuery(document).ready(function()
// jQuery('.input').keypress(function(e)
// if (e.which == 13)
// alert('ok');
// $('#custom-form').submit();
// return false;
//
// );
jQuery(document).keypress(function(event)
var keycode = (event.keyCode ? event.keyCode : event.which);
if(keycode == '13')
//alert('You pressed a "enter" key in somewhere');
jQuery('#custom-form').submit();
return false;
jQuery("#custom-form").validate(
rules:
first_name: "required",
last_name: "required",
email:
required: true,
email: true
,
phone_no:
required:true,
number:true
,
address1: "required",
city: "required",
region: "required",
postcode: "required",
authenticity: "required",
style: "required",
retailer: "required"
,
messages:
first_name: "Please enter your Firstname",
last_name: "Please enter your Lastname",
email: "Please enter a valid Email Address",
phone_no:
required: "Please enter your Phone Number",
number:"Please enter numbers Only"
,
address1: "Please enter your Address",
city: "Please enter your City",
region: "Please enter your State/Province",
postcode: "Please enter your Zipcode",
authenticity: "Please enter your Authenticity",
style: "Please enter your Style",
retailer: "Please enter your Retailer"
,
submitHandler: function(form, event)
event.preventDefault();
// alert("Do some stuff...");
form.submit();
//submit via ajax
);
);
);
</script>
Any help would be appreciated.
magento2 jquery form-validation
add a comment |
I have used jQuery validation, but it is not working on pressing enter key in Magento2.2.5?
But works on Submit button.
Refer my code.
<script src="http://ajax.aspnetcdn.com/ajax/jquery.validate/1.11.1/jquery.validate.min.js"></script>
<script type="text/javascript">
require([
'jquery'
], function($){
// jQuery(document).ready(function()
// jQuery('.input').keypress(function(e)
// if (e.which == 13)
// alert('ok');
// $('#custom-form').submit();
// return false;
//
// );
jQuery(document).keypress(function(event)
var keycode = (event.keyCode ? event.keyCode : event.which);
if(keycode == '13')
//alert('You pressed a "enter" key in somewhere');
jQuery('#custom-form').submit();
return false;
jQuery("#custom-form").validate(
rules:
first_name: "required",
last_name: "required",
email:
required: true,
email: true
,
phone_no:
required:true,
number:true
,
address1: "required",
city: "required",
region: "required",
postcode: "required",
authenticity: "required",
style: "required",
retailer: "required"
,
messages:
first_name: "Please enter your Firstname",
last_name: "Please enter your Lastname",
email: "Please enter a valid Email Address",
phone_no:
required: "Please enter your Phone Number",
number:"Please enter numbers Only"
,
address1: "Please enter your Address",
city: "Please enter your City",
region: "Please enter your State/Province",
postcode: "Please enter your Zipcode",
authenticity: "Please enter your Authenticity",
style: "Please enter your Style",
retailer: "Please enter your Retailer"
,
submitHandler: function(form, event)
event.preventDefault();
// alert("Do some stuff...");
form.submit();
//submit via ajax
);
);
);
</script>
Any help would be appreciated.
magento2 jquery form-validation
$('.input').keypress(function(e) if (e.which == 13) alert('ok'); $('#form-id').submit(); return false; );
– Prathap Gunasekaran
22 hours ago
add a comment |
I have used jQuery validation, but it is not working on pressing enter key in Magento2.2.5?
But works on Submit button.
Refer my code.
<script src="http://ajax.aspnetcdn.com/ajax/jquery.validate/1.11.1/jquery.validate.min.js"></script>
<script type="text/javascript">
require([
'jquery'
], function($){
// jQuery(document).ready(function()
// jQuery('.input').keypress(function(e)
// if (e.which == 13)
// alert('ok');
// $('#custom-form').submit();
// return false;
//
// );
jQuery(document).keypress(function(event)
var keycode = (event.keyCode ? event.keyCode : event.which);
if(keycode == '13')
//alert('You pressed a "enter" key in somewhere');
jQuery('#custom-form').submit();
return false;
jQuery("#custom-form").validate(
rules:
first_name: "required",
last_name: "required",
email:
required: true,
email: true
,
phone_no:
required:true,
number:true
,
address1: "required",
city: "required",
region: "required",
postcode: "required",
authenticity: "required",
style: "required",
retailer: "required"
,
messages:
first_name: "Please enter your Firstname",
last_name: "Please enter your Lastname",
email: "Please enter a valid Email Address",
phone_no:
required: "Please enter your Phone Number",
number:"Please enter numbers Only"
,
address1: "Please enter your Address",
city: "Please enter your City",
region: "Please enter your State/Province",
postcode: "Please enter your Zipcode",
authenticity: "Please enter your Authenticity",
style: "Please enter your Style",
retailer: "Please enter your Retailer"
,
submitHandler: function(form, event)
event.preventDefault();
// alert("Do some stuff...");
form.submit();
//submit via ajax
);
);
);
</script>
Any help would be appreciated.
magento2 jquery form-validation
I have used jQuery validation, but it is not working on pressing enter key in Magento2.2.5?
But works on Submit button.
Refer my code.
<script src="http://ajax.aspnetcdn.com/ajax/jquery.validate/1.11.1/jquery.validate.min.js"></script>
<script type="text/javascript">
require([
'jquery'
], function($){
// jQuery(document).ready(function()
// jQuery('.input').keypress(function(e)
// if (e.which == 13)
// alert('ok');
// $('#custom-form').submit();
// return false;
//
// );
jQuery(document).keypress(function(event)
var keycode = (event.keyCode ? event.keyCode : event.which);
if(keycode == '13')
//alert('You pressed a "enter" key in somewhere');
jQuery('#custom-form').submit();
return false;
jQuery("#custom-form").validate(
rules:
first_name: "required",
last_name: "required",
email:
required: true,
email: true
,
phone_no:
required:true,
number:true
,
address1: "required",
city: "required",
region: "required",
postcode: "required",
authenticity: "required",
style: "required",
retailer: "required"
,
messages:
first_name: "Please enter your Firstname",
last_name: "Please enter your Lastname",
email: "Please enter a valid Email Address",
phone_no:
required: "Please enter your Phone Number",
number:"Please enter numbers Only"
,
address1: "Please enter your Address",
city: "Please enter your City",
region: "Please enter your State/Province",
postcode: "Please enter your Zipcode",
authenticity: "Please enter your Authenticity",
style: "Please enter your Style",
retailer: "Please enter your Retailer"
,
submitHandler: function(form, event)
event.preventDefault();
// alert("Do some stuff...");
form.submit();
//submit via ajax
);
);
);
</script>
Any help would be appreciated.
magento2 jquery form-validation
magento2 jquery form-validation
edited 19 hours ago
Amy
asked 22 hours ago
AmyAmy
3399
3399
$('.input').keypress(function(e) if (e.which == 13) alert('ok'); $('#form-id').submit(); return false; );
– Prathap Gunasekaran
22 hours ago
add a comment |
$('.input').keypress(function(e) if (e.which == 13) alert('ok'); $('#form-id').submit(); return false; );
– Prathap Gunasekaran
22 hours ago
$('.input').keypress(function(e) if (e.which == 13) alert('ok'); $('#form-id').submit(); return false; );
– Prathap Gunasekaran
22 hours ago
$('.input').keypress(function(e) if (e.which == 13) alert('ok'); $('#form-id').submit(); return false; );
– Prathap Gunasekaran
22 hours ago
add a comment |
1 Answer
1
active
oldest
votes
To check if an enter key is pressed on page, bind the keypress()
to the jQuery $(document)
.
$(document).keypress(function(event)
var keycode = (event.keyCode ? event.keyCode : event.which);
if(keycode == '13')
alert('You pressed a "enter" key in somewhere');
);
to check if the submit button is pressed
$("#myButton").click(function()
alert("Click code executed.");
);
Its working for keypress, but on submit button it is not validating.
– Amy
19 hours ago
I have updated my question. check it..
– Amy
19 hours ago
have you tied$("#formselector").submit(function() alert("Button code executed."););
or$("#myButton").click(function() alert("Click code executed."); );
– Ghulam.M
19 hours ago
$("#myButton").click(function() worked for me..
– Amy
18 hours ago
Thank u.. now it is working for both..
– Amy
18 hours ago
|
show 2 more comments
Your Answer
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "479"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f268464%2fjquery-validation-not-working-on-pressing-enter-key-in-magento2-2-5%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
To check if an enter key is pressed on page, bind the keypress()
to the jQuery $(document)
.
$(document).keypress(function(event)
var keycode = (event.keyCode ? event.keyCode : event.which);
if(keycode == '13')
alert('You pressed a "enter" key in somewhere');
);
to check if the submit button is pressed
$("#myButton").click(function()
alert("Click code executed.");
);
Its working for keypress, but on submit button it is not validating.
– Amy
19 hours ago
I have updated my question. check it..
– Amy
19 hours ago
have you tied$("#formselector").submit(function() alert("Button code executed."););
or$("#myButton").click(function() alert("Click code executed."); );
– Ghulam.M
19 hours ago
$("#myButton").click(function() worked for me..
– Amy
18 hours ago
Thank u.. now it is working for both..
– Amy
18 hours ago
|
show 2 more comments
To check if an enter key is pressed on page, bind the keypress()
to the jQuery $(document)
.
$(document).keypress(function(event)
var keycode = (event.keyCode ? event.keyCode : event.which);
if(keycode == '13')
alert('You pressed a "enter" key in somewhere');
);
to check if the submit button is pressed
$("#myButton").click(function()
alert("Click code executed.");
);
Its working for keypress, but on submit button it is not validating.
– Amy
19 hours ago
I have updated my question. check it..
– Amy
19 hours ago
have you tied$("#formselector").submit(function() alert("Button code executed."););
or$("#myButton").click(function() alert("Click code executed."); );
– Ghulam.M
19 hours ago
$("#myButton").click(function() worked for me..
– Amy
18 hours ago
Thank u.. now it is working for both..
– Amy
18 hours ago
|
show 2 more comments
To check if an enter key is pressed on page, bind the keypress()
to the jQuery $(document)
.
$(document).keypress(function(event)
var keycode = (event.keyCode ? event.keyCode : event.which);
if(keycode == '13')
alert('You pressed a "enter" key in somewhere');
);
to check if the submit button is pressed
$("#myButton").click(function()
alert("Click code executed.");
);
To check if an enter key is pressed on page, bind the keypress()
to the jQuery $(document)
.
$(document).keypress(function(event)
var keycode = (event.keyCode ? event.keyCode : event.which);
if(keycode == '13')
alert('You pressed a "enter" key in somewhere');
);
to check if the submit button is pressed
$("#myButton").click(function()
alert("Click code executed.");
);
edited 18 hours ago
answered 20 hours ago
Ghulam.MGhulam.M
19511
19511
Its working for keypress, but on submit button it is not validating.
– Amy
19 hours ago
I have updated my question. check it..
– Amy
19 hours ago
have you tied$("#formselector").submit(function() alert("Button code executed."););
or$("#myButton").click(function() alert("Click code executed."); );
– Ghulam.M
19 hours ago
$("#myButton").click(function() worked for me..
– Amy
18 hours ago
Thank u.. now it is working for both..
– Amy
18 hours ago
|
show 2 more comments
Its working for keypress, but on submit button it is not validating.
– Amy
19 hours ago
I have updated my question. check it..
– Amy
19 hours ago
have you tied$("#formselector").submit(function() alert("Button code executed."););
or$("#myButton").click(function() alert("Click code executed."); );
– Ghulam.M
19 hours ago
$("#myButton").click(function() worked for me..
– Amy
18 hours ago
Thank u.. now it is working for both..
– Amy
18 hours ago
Its working for keypress, but on submit button it is not validating.
– Amy
19 hours ago
Its working for keypress, but on submit button it is not validating.
– Amy
19 hours ago
I have updated my question. check it..
– Amy
19 hours ago
I have updated my question. check it..
– Amy
19 hours ago
have you tied
$("#formselector").submit(function() alert("Button code executed."););
or $("#myButton").click(function() alert("Click code executed."); );
– Ghulam.M
19 hours ago
have you tied
$("#formselector").submit(function() alert("Button code executed."););
or $("#myButton").click(function() alert("Click code executed."); );
– Ghulam.M
19 hours ago
$("#myButton").click(function() worked for me..
– Amy
18 hours ago
$("#myButton").click(function() worked for me..
– Amy
18 hours ago
Thank u.. now it is working for both..
– Amy
18 hours ago
Thank u.. now it is working for both..
– Amy
18 hours ago
|
show 2 more comments
Thanks for contributing an answer to Magento Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f268464%2fjquery-validation-not-working-on-pressing-enter-key-in-magento2-2-5%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
$('.input').keypress(function(e) if (e.which == 13) alert('ok'); $('#form-id').submit(); return false; );
– Prathap Gunasekaran
22 hours ago