简体   繁体   English

如何在Yii2表单文本字段中设置标点符号?

[英]How to set punctuation in Yii2 form text field?

I've a form in my Yii2 application. 我的Yii2应用程序中有一个表格。 I'm using Kartik\\form\\activeFor. 我正在使用Kartik \\ form \\ activeFor。 This is a little view of my form 这是我的形式的一点看法 在此处输入图片说明

And this is the code 这是代码

'jumlahBruto' => ['type' => Form::INPUT_TEXT, 'options' => ['placeholder' => 'Nilai Total Bruto...'];

How do I can set the data in text field has a dot like this 我如何设置文本字段中的数据有这样的 在此处输入图片说明

Thanks. 谢谢。

Here is your code for masking 这是您屏蔽的代码

 jQuery(function($) { $("#date").mask("99.999.999"); }); 
 <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery.maskedinput/1.4.1/jquery.maskedinput.min.js"></script> <input id="date" type="text"> 

This will solve your problem. 这样可以解决您的问题。

EDIT 编辑

As mentioned in documentation, in modal dom is already not loaded. 如文档中所述,模态dom中尚未加载。
You need to explicitely call input mask for dynamically loaded elements. 您需要为动态加载的元素显式调用输入掩码。

$(":input").inputmask(); $(document).on("ajaxComplete", function(e){ 
   $(":input").inputmask(); 
});

as per author of inputmask here is the link . 根据inputmask的作者,这是链接

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM