Forum Moderators: open

Message Too Old, No Replies

Form Values & Strings

Need to replace commas with empty strings...

         

Eric_Lander

7:05 pm on Jan 20, 2005 (gmt 0)

10+ Year Member



I have a form, called "PostForm" that passes a value for the field named "Price". I want to, with javascript, detect if the value for "Price" contains any commas, and if so, replace them with an empty string.

Any suggestions?

birdbrain

8:14 pm on Jan 20, 2005 (gmt 0)



Hi there Eric_Lander,

try this...

<script type="text/javascript">
<!--

function removeCommas() {
var df=document.forms[0][0];
df.value=df.value.replace(/,/g,"")
}

//-->
</script>

<form action="#">
<div>
<input type="text" onchange="removeCommas()"/>
</div>
</form>

birdbrain