在文本表单字段输入中添加特殊字符 [Flutter]
在经典的文本表单字段小部件中,我想在用户输入输入时自动将“/”字符放在第四个字符后面。我该怎么做?
感谢您的帮助!
输入示例 2012/324234
OcasTextFormFieldContent(
maxLength: 12,
inputType: TextInputType.number,
validator: (String? fieldContent) {
if (fieldContent == "" || fieldContent == null) {
return 'not empty';
} else if (fieldContent.length < 12) {
return 'wrong type.';
} else {
return null;
}
},
controller: _dosyaNo,
name: "Doc No: ",
placeholder: "Please enter doc no"),
In a classic textformfield widget, I want to put the "/" character automatically after the fourth character when the user enters input. How can I do this?
Thanks for help!
Example input
2012/324234
OcasTextFormFieldContent(
maxLength: 12,
inputType: TextInputType.number,
validator: (String? fieldContent) {
if (fieldContent == "" || fieldContent == null) {
return 'not empty';
} else if (fieldContent.length < 12) {
return 'wrong type.';
} else {
return null;
}
},
controller: _dosyaNo,
name: "Doc No: ",
placeholder: "Please enter doc no"),
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果要自动添加
/
,则可以使用TextField的Onchange属性。您可以在
onChange
属性中添加以下代码If you want to add
/
automatically, you can use onChange property of TextField.You can add following code in
onChange
property