//this.pro[index].sysNum=this.pro[index].sysNum.replace(/[^\d]/g,'');
//先把非数字的都替换掉,除了数字和.
this.pro[index].sysNum = this.pro[index].sysNum.replace(/[^\d.]/g,"");

//保证只有出现一个.而没有多个.
this.pro[index].sysNum = this.pro[index].sysNum.replace(/\.{2,}/g,".");
//必须保证第一个为数字而不是.

this.pro[index].sysNum = this.pro[index].sysNum.replace(/^\./g,"");

//保证.只出现一次,而不能出现两次以上

this.pro[index].sysNum = this.pro[index].sysNum.replace(".","$#$").replace(/\./g,"").replace("$#$",".");

//只能输入两个小数

this.pro[index].sysNum = this.pro[index].sysNum.replace(/^(\-)*(\d+)\.(\d\d\d\d).*$/,'$1$2.$3');
posted on 2019-08-30 13:42  一抹书香  阅读(4260)  评论(0编辑  收藏  举报