Removing Commas from an input text field with Jquery

I am looking for a solution using Jquery that would mask / remove commas that are inserted into a input (numeric) text field in a form. I have done some research on my own and found a pluggin that does the job http://www.decorplanit.com/plugin/)... unfortunately my understanding of Jquery is limited.

Can someone help me complete the code attached or give me something that I can implement?  I like the idea of using Jquery as it makes the change on the fly and is visual to the end user.

Any thoughts would be greatly appreciated
<!--USED TO REMOVE COMMAS FROM TXT FIELDS http://www.decorplanit.com/plugin/publicFunctions.htm-->
<script src="../../Scripts/jquery-1.4.2.js" type="text/javascript"></SCRIPT>
 <SCRIPT src="../../Scripts/AutoNumberic/jquery.metadata.js" type=text/javascript></SCRIPT> //needed if changing defaults 
<script src="../../Scripts/AutoNumberic/autoNumeric-1.6.2.js" type="text/javascript"></SCRIPT>
<script src="../../Scripts/AutoNumberic/autoLoader.js" type="text/javascript"></SCRIPT>

<script type="text/javascript"> //I don't think the code here is legit
 $(document).ready(function() {
	$.fn.autoNumeric.Strip(dollarvalue, {options} );
 });
</script> 

//// input txt field /////
<input class="strip" type="text" name="dollarvalue" id="dollarvalue" />

Open in new window

LVL 1
jasch2244Asked:
Who is Participating?
 
Gurvinder Pal SinghConnect With a Mentor Commented:
or even better

<input type="text" onkeyup="this.value=this.value.replace(',','')" value="" />

0
 
leakim971PluritechnicianCommented:
If by removing you mean don't allow :

Use :
$("#dollarvalue").autoNumeric();

Open in new window


Or :
$.fn.autoNumeric.Strip("#dollarvalue");

Open in new window

0
 
jasch2244Author Commented:
Yes, I would like to not allow commas to be entered.

Both of the suggestions did not work the second did some formatting for me by adding decimals .00 to the end but that is it... no commas were removed. On the site they mentioned under the strip section that the # signs are to be ommited (http://www.decorplanit.com/plugin/publicFunctions.htm)

Any other suggestions? My new code per your suggestion is attached
<script src="../../Scripts/jquery-1.4.2.js" type="text/javascript"></SCRIPT>
<SCRIPT src="../../Scripts/AutoNumberic/jquery.metadata.js" type=text/javascript></SCRIPT> //needed if changing defaults 
<script src="../../Scripts/AutoNumberic/autoNumeric-1.6.2.js" type="text/javascript"></SCRIPT>
<script src="../../Scripts/AutoNumberic/autoLoader.js" type="text/javascript"></SCRIPT>
<script type="text/javascript"> //I don't think the code here is legit
	 $(document).ready(function() {
		$("dollarvalue").autoNumeric(); 
 });
</script>

Open in new window

0
Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

 
jasch2244Author Commented:
One other thought I added the $(document).ready(function() and put the other fucntion mentioned on the site in the middle... thinking this was proper. I don't know if it is or not I know that is states once the document is fully loaded do the function contained with in but it might be out of context.
0
 
Gurvinder Pal SinghCommented:
something like this?

 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script language="javascript">
function checkInput(ob)
{
  if(/,/gi.test(ob.value)) {
        alert("Invalid characters.");
            ob.value = ob.value.substring(0,ob.value.length-1);
      }
}
</script>
</head>

<body>
<textarea onkeyup="checkInput(this)"></textarea>
</body>
</html>
0
 
jasch2244Author Commented:
Thank you, but no I want it to auto remove as people type and/or paste info into text field.
0
 
Gurvinder Pal SinghCommented:
replace if condition contents with

return false;
0
 
jasch2244Author Commented:
My coding is aweful can you show me a full example? Sorry
0
 
Gurvinder Pal SinghCommented:
last one should be enough, please check that one first
0
 
jasch2244Author Commented:
Easy enough! Thank you
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.