Reputation: 25
I'm using jquery to strip commas from a form field on submit so the form plays nice with the next step. The jquery script works in Chrome and Firefox but not IE.
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js" type="text/javascript"></script>
<script>
$(document).ready(function(){
$("#submit").click(function () {
$(price1).val( $(price1).val().replace(/,/g,'') );
});
});</script>
and the form field is simply:
<input name="price1" id="price1" value="" size="32">
What am I missing? Any suggestions?
Upvotes: 2
Views: 71
Reputation: 25
That worked! The commas are stripped and I actually understand your solution. Thank you
Upvotes: 0
Reputation: 782785
Change $(price1)
to $("#price1")
. Some browsers turn all IDs into global variables, but this isn't the standard way to access them.
Upvotes: 3