其他分享
首页 > 其他分享> > input在HTML校验正负数特殊字符

input在HTML校验正负数特殊字符

作者:互联网

swal({
title: '',
html:
'<p style="font-weight:bold;">Please input adjusted amount</p>' +
'<input type="text" style="width:310px;height:35px;" id="adjustedAmountInput" placeholder="+500/-500" onKeyUp="if(isNaN(value)&&!/^-$/.test(value))value=\'\';if(!/^[+-]?\.{0,1}\d{0,1}$/.test(value))value = value.replace(/\.\d{2,}$/,value.substr(value.indexOf(\'.\'),3))">' +
'</br></br><p style="font-weight:bold;">Comment</p>' +
'<textarea id="commentTextArea" type="text" name="fname" style="width:380px;height:125px;resize:none;margin-bottom:-15px;" placeholder="This is the reminder for clicking Edit "/></textarea>' ,
showCancelButton: true,
confirmButtonText: 'SAVE',
cancelButtonText: 'CANCEL',
}).then((isConfirm) => {
try {

 

 


主要需要注意if判断,转义字符

 

'<input type="text" style="width:310px;height:35px;" id="adjustedAmountInput" placeholder="+500/-500" onKeyUp="if(isNaN(value)&&!/^-$/.test(value))value=\'\';if(!/^[+-]?\.{0,1}\d{0,1}$/.test(value))value = value.replace(/\.\d{2,}$/,value.substr(value.indexOf(\'.\'),3))">' +

标签:adjusted,title,Please,正负数,转义字符,HTML,input
来源: https://www.cnblogs.com/mmit/p/14116581.html