Questions tagged «prototype-js»

2
自定义表单验证-Magento
我正在尝试使用jQuery在Magento中实现一些自定义表单验证,但是我不确定我是否具有正确的方法。 基本上,我需要验证以下内容: 仅数字字段需要具有.00才能验证1到1.00 字母必须大写 号码不能大于9.99 字段中没有空格 我正在考虑使用jQuery,并着手编写一些东西来验证表单: <script> jQuery(document).ready(function() { jQuery.validator.addMethod("integer", function(value, element) { return this.optional(element) || /^-?\d+$/.test(value); }, "A positive or negative non-decimal number please"); function(field, length) { if (!numericRegex.test(length)) { return false; } return (field.value.length <= parseInt(length, 4)); }, } </script> 问题是我找不到其他验证字段的功能,请提供一些帮助。

1
如何在magento 2中将变量传递给外部js
在magento 1中 例如,我们可以在phtml中调用此原型函数 function ABC(){ var a = '<?php echo $a;?>' alert(a); } 但是在magento 2中,我们不能在phtml中添加这种类型的函数,为此我们必须创建 requirejs-config.js var config = { map: { '*': { 'exam': 'js/example', } } }; 像这样和example.js function ABC(){ alert(a); } 在phtml中 require(['jquery','exam'], function($){ var a= <?php echo $a; ?>; }); 我正在尝试像这样传递变量,但无法正常工作,如何在magento 2中将变量从phtml传递给外部js
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.