Solved

How can I format my number with this jquery library?

Posted on 2010-08-20
18
288 Views
Last Modified: 2012-05-10
Hello guys,

I downloaded this library and I need to format my value this way: 1.963,35

How can I do this with this library, I didn't find any example with it for that

http://digitalbush.com/projects/masked-input-plugin/


thanks
0
Comment
Question by:hidrau
[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
  • 10
  • 8
18 Comments
 
LVL 82

Accepted Solution

by:
leakim971 earned 500 total points
ID: 33484488
Use :


$(document).ready(function() {
		$(".num").mask("999.999,99");
	});

Open in new window

0
 
LVL 82

Expert Comment

by:leakim971
ID: 33484497
test page :


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<script language="javascript" src="http://code.jquery.com/jquery-1.4.2.min.js"></script>
<script language="javascript" src="http://jquery-joshbush.googlecode.com/files/jquery.maskedinput-1.2.2.min.js"></script>
<script language="javascript">
	$(document).ready(function() {
		$(".num").mask("999.999,99");
	});
</script>
</head>
<body>
<input type="text" class="num" /><br />
<input type="text" class="num" /><br />
<input type="text" /><br />
<input type="text" /><br />
</body>
</html>

Open in new window

0
 
LVL 1

Author Comment

by:hidrau
ID: 33484617
Yeah, it worked very fine, but I noticed that I have a big problem and I don't know why.

When I open my page, I have some fields with values, I run my asp query that return values and I pass the values to variables that is displayed in input, this way:

<input name="Faliqicms"     type="text" class="Campos numero" id="Faliqicms"     value="<%=AliqIcms%>"  />

Using the mask, the values is not being displayed, do you know why?
0
Don't Cry: How Liquid Web is Ensuring Security

WannaCry is just the start. Read how Liquid Web is protecting itself and its customers against new threats.

 
LVL 82

Expert Comment

by:leakim971
ID: 33484707
The plugin don't work in that way. It's to check inputs from user not from server side or at page loading.
Try, if possible, to format the number before set it as value
0
 
LVL 1

Author Comment

by:hidrau
ID: 33484815
Yeah,

I formated the number this way:

AliqIcms =  FormatNumber(Rs("RecNf_TotalNF"))      

but nothing is displaying in the field
0
 
LVL 82

Expert Comment

by:leakim971
ID: 33484932
sorry for this question but without the class do you get something ? I think you miss something server side. I should work.
 
0
 
LVL 82

Expert Comment

by:leakim971
ID: 33484938
I can confirm you the plugin format number at pageload too
0
 
LVL 1

Author Comment

by:hidrau
ID: 33484985
Take a look at my page.


page.txt
0
 
LVL 82

Expert Comment

by:leakim971
ID: 33486240
For example, try to replace something like :
< input name="Fnfe" type="text" class="Campos" id="Fnfe" value="<%=Nfe%>" / >

With :
< input name="Fnfe" type="text" class="Campos" id="Fnfe" value="12345.67" / >

0
 
LVL 1

Author Comment

by:hidrau
ID: 33486359
I will try
0
 
LVL 1

Author Comment

by:hidrau
ID: 33500014
Leak, I tried it and nothing :((

very strange, it works with you?
0
 
LVL 82

Expert Comment

by:leakim971
ID: 33500032
Yes Sir! And at page load! Do you have a live link to test it ?
0
 
LVL 1

Author Comment

by:hidrau
ID: 33500068
well, I will make some test in a clean page and I will let you know.

Thanks for keeping up with me on this thread.

0
 
LVL 82

Expert Comment

by:leakim971
ID: 33500072
np
0
 
LVL 1

Author Comment

by:hidrau
ID: 33501241
Leak, I didn't have a good success with it.

But a friend of mine told me to use this library

http://plugins.jquery.com/project/maskinputmoney

take a look at
0
 
LVL 82

Expert Comment

by:leakim971
ID: 33501294
I check again your page.txt, I did'nt see where you include the jquery and the masked input jquery pluginS
0
 
LVL 1

Author Comment

by:hidrau
ID: 33503852
leak, I got it with that library.

I thank you for your support so far
0
 
LVL 82

Expert Comment

by:leakim971
ID: 33503866
You're very welcome! See you later! Thanks for the points!
0

Featured Post

Is Your Team Achieving Their Full Potential?

74% of employees feel they are not achieving their full potential. With Linux Academy, not only will you strengthen your team's core competencies but also their knowledge of of the newest IT topics.

With new material every week, we'll make sure that you stay ahead of the game.

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 If you're like most people, you have occasionally made a typographical error when you're entering information into an online form.  And to your consternation, the browser remembers the error, and offers to autocomplete your future entr…
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…

726 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