Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Jquery and checking for leading pound sign

Posted on 2013-05-31
3
Medium Priority
?
442 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 82

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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

I found this questions asking how to do this in many different forums, so I will describe here how to implement a solution using PHP and AJAX. The logical flow for the problem should be: Write an event handler for the first drop down box to get …
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
The viewer will learn the basics of jQuery, including how to invoke it on a web page. 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.: (CODE)
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

636 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