Jquery and checking for leading pound sign

Posted on 2013-05-31
Last Modified: 2013-05-31
Hello experts,

is there any way of making sure than an input has a £ sign at the start on blur? without using a plugin?

Many thanks in advance
Question by:maccaj51
LVL 82

Accepted Solution

leakim971 earned 500 total points
ID: 39210492
Test page :
$(document).ready(function() {
     $("#inputID").blur(function() {
            var value = "£" + $(this).val().replace(/£/g,"");

Open in new window


Expert Comment

ID: 39210494
inside blur event

if (string_var_from_input.match(/^£/) != null) {


Author Closing Comment

ID: 39210503
Always to the rescue leakim971! Many thanks

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Download a website to hdd 2 49
popup load of page and setting up of session 8 25
Detect change of Select using JavaScript Only 12 45
Sorting a string 1 10
Introduction Got endorsements from your clients?  Great!  There is almost nothing better than word-of-mouth advertising.  But how can you do that on the internet?  Sure you can make a page for endorsement quotations and list them all, but who is …
PROBLEM: The other day I was working on adding an ajax request to a webpage that already had a dialog box on the page.  The dialog box was using relative positioning to be positioned next to a form field I had on the page.  Everything was working…
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now