How to remove alpha characters from string using jQuery


 
jQuery for remove alpha characters from string.

If your string is :

var myString = ‘<jainish> 143.8 Text’;

and you want numeric value, dot and dash in your string then you have to use following jQuery

var myString = myString.replace(/[^\d.-]/g, '');
alert(myString)

And output will be :

143.8

If you want only numeric value then Following should do the trick.

var myString = myString.replace(/[^\d]/g, '');
alert(myString)

And output will be :

1438

If you have any queries, please do not hesitate to contact me at Jainish Senjaliya

Advertisements

One thought on “How to remove alpha characters from string using jQuery

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s