How to resolve `.` in my regex?

I use this code to prevent special characters

String.prototype.isText = function () {return /^[\w\s&'%]*$/.test(this)} 

But I want it to allow points to be entered into a string.

How can I change it for this?

thanks

+4
source share
2 answers

Add a point:

 String.prototype.isText = function () {return /^[\w\s&'%.]*$/.test(this)} 
+10
source
 String.prototype.isText = function () {return /^[\.\w\s&'%]*$/.test(this)} 
+8
source

All Articles