Hi,

Im looking for an easy method to validate the input of a form. Ideally I want to remove all spaces from the inputed text and also ensure that there are no speical characters within it other then a forward slash.

The input will look like this 192.168.1.1/24.

Thanks,

Recommended Answers

All 3 Replies

Felix,

Strictly speaking, that's not validation (testing); it's sanitisation (modification).

Both validation and sanitisation can be performed with regular expressions as @stb says.

fast fix

[input].match(/[\d/]+/g).join('.');

might do the trick...

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.