?
Solved

Jquery and checking for leading pound sign

Posted on 2013-05-31
3
Medium Priority
?
448 Views
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
0
Comment
Question by:maccaj51
3 Comments
 
LVL 83

Accepted Solution

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

Open in new window

0
 
LVL 9

Expert Comment

by:TvMpt
ID: 39210494
try:
inside blur event

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

}
0
 

Author Closing Comment

by:maccaj51
ID: 39210503
Always to the rescue leakim971! Many thanks
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

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…
Introduction Knockoutjs (Knockout) is a JavaScript framework (Model View ViewModel or MVVM framework).   The main ideology behind Knockout is to control from JavaScript how a page looks whilst creating an engaging user experience in the least …
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…
Suggested Courses
Course of the Month13 days, 8 hours left to enroll

750 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