0

i have a custom form.html that displays at checkout. i want to have a javascript tag - when the form load just show an alert testing purposes.

code i used below,

"<script type="text/javascript">
require(['jquery', 'jquery/ui'], function($){ 
 $('document').ready(function(){
 console.log("this")
 alert('Load');
 document.getElementById('pinverify').style.display = "none";
 document.getElementById('labelBalance').style.display = "none";
 document.getElementById('payment[custom_field_one]').value =""; 
 document.getElementById('OTP').value= "";
 document.getElementById('payment[custom_field_three]').value = "";
 $('#verify').click(function(){
 checkOTPField();
 });
"

but this alias does not work, is there a different alias used in magento 2?

Thank you

asked Sep 26, 2018 at 13:46
5
  • Can you give the path to this .html file. Commented Sep 26, 2018 at 13:51
  • [namespace]/[ModuleName]/view/frontend/web/template/payment/form.html Commented Sep 26, 2018 at 13:54
  • Can you describe your purpose? Commented Sep 26, 2018 at 14:15
  • i have created a custom form i have a textbox on the form aswell as a button i would like to run the javscript for that button within the html form $(button).click function - but its not allowing me to do that Commented Sep 26, 2018 at 14:47
  • Hey have you override this from (web/template/payment/form.html) from any core module? @RadhiyahWilliams Commented Sep 27, 2018 at 6:54

1 Answer 1

0

Assuming that you checked and do not have any error in your js code. Possible reason for the changes to not reflect is that you did not run the content:deploy command after making the changes:

Please run the below commands:

bin/magento cache:clean
bin/magento setup:static-content:deploy
answered Sep 26, 2018 at 13:54

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.