如何在MUI Textfield中实现文本蒙版
因此,我想以价格和信用卡编号为我的MUI Textfields实施口罩,但如何使用。例如,我希望Texfield的价格从“ $”开始,并以“ - ”分开卡号。我已经尝试了此主题,但是它行不通。这是我的Textfields之一:
<TextField
required
className="form__input"
id="price"
name="price"
value={formData.price}
label="Ticket Price"
variant="outlined"
type="number"
onChange={(event) => eventHandleChange(event)}
error={!/(^$)|(^[+]?\d+([.]\d+)?$)/.test(formData.price)}
helperText={
!/(^$)|(^[+]?\d+([.]\d+)?$)/.test(formData.price) &&
validations.positiveNumbersOnly
}
/>
So I want to implement a mask to my mui Textfields for price and credit card number, but idk how. For example I want the price texfield to start with "$", and the card number to be separated with "-". I've tried the things from this topic , but it doesn't work. Here is one of my textfields:
<TextField
required
className="form__input"
id="price"
name="price"
value={formData.price}
label="Ticket Price"
variant="outlined"
type="number"
onChange={(event) => eventHandleChange(event)}
error={!/(^$)|(^[+]?\d+([.]\d+)?$)/.test(formData.price)}
helperText={
!/(^$)|(^[+]?\d+([.]\d+)?$)/.test(formData.price) &&
validations.positiveNumbersOnly
}
/>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
![扫码二维码加入Web技术交流群](/public/img/jiaqun_03.jpg)
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论