jeudi 21 juillet 2016

Replace characters other then numbers and '-' sign using regex expression

I am trying to add validation for a number type input box, for which I have tried the below codes, this.value = this.value.replace(/[^d.]/ig,''); this.value = this.value.replace(/[^0-9.]/ig,''); this.value = this.value.replace(/[^0-9.-]/g,''); this.value = this.value.replace(/(?!-)[^0-9.]/g,''); this.value = this.value.replace(/[^0-9.-]/g,''); Actually I want to replace all the characters entered (other than numbers, '.' and '-') into the input box with blank. But none of the above are working for me. Please help. Thanks and Regards, Neha

Aucun commentaire:

Enregistrer un commentaire