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













0















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.










share|improve this question
























  • $('.input').keypress(function(e) if (e.which == 13) alert('ok'); $('#form-id').submit(); return false; );

    – Prathap Gunasekaran
    22 hours ago















0















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.










share|improve this question
























  • $('.input').keypress(function(e) if (e.which == 13) alert('ok'); $('#form-id').submit(); return false; );

    – Prathap Gunasekaran
    22 hours ago













0












0








0








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.










share|improve this question
















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






share|improve this question















share|improve this question













share|improve this question




share|improve this question








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

















  • $('.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










1 Answer
1






active

oldest

votes


















0














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.");


);






share|improve this answer

























  • 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











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
);



);













draft saved

draft discarded


















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









0














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.");


);






share|improve this answer

























  • 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















0














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.");


);






share|improve this answer

























  • 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













0












0








0







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.");


);






share|improve this answer















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.");


);







share|improve this answer














share|improve this answer



share|improve this answer








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

















  • 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

















draft saved

draft discarded
















































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.




draft saved


draft discarded














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





















































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







Popular posts from this blog

Get product attribute by attribute group code in magento 2get product attribute by product attribute group in magento 2Magento 2 Log Bundle Product Data in List Page?How to get all product attribute of a attribute group of Default attribute set?Magento 2.1 Create a filter in the product grid by new attributeMagento 2 : Get Product Attribute values By GroupMagento 2 How to get all existing values for one attributeMagento 2 get custom attribute of a single product inside a pluginMagento 2.3 How to get all the Multi Source Inventory (MSI) locations collection in custom module?Magento2: how to develop rest API to get new productsGet product attribute by attribute group code ( [attribute_group_code] ) in magento 2

Category:9 (number) SubcategoriesMedia in category "9 (number)"Navigation menuUpload mediaGND ID: 4485639-8Library of Congress authority ID: sh85091979ReasonatorScholiaStatistics

Magento 2.3: How do i solve this, Not registered handle, on custom form?How can i rewrite TierPrice Block in Magento2magento 2 captcha not rendering if I override layout xmlmain.CRITICAL: Plugin class doesn't existMagento 2 : Problem while adding custom button order view page?Magento 2.2.5: Overriding Admin Controller sales/orderMagento 2.2.5: Add, Update and Delete existing products Custom OptionsMagento 2.3 : File Upload issue in UI Component FormMagento2 Not registered handleHow to configured Form Builder Js in my custom magento 2.3.0 module?Magento 2.3. How to create image upload field in an admin form