I’ve done some Googling but haven’t been able to get this working. What I need to do is look through all of the TEXT fields in my form and replace all instances of “,” (comma) with ” & # 4 4 ;” (escaped comma) on submit.
Here is the form tag:
<form name="buildcourse" id="buildcourse" action="target.htm" method="post" enctype="multipart/form-data" onsubmit="validateForm()">
And here is my javascript function:
<script language="javascript">
function validateForm(buildcourse){
$('form input[type="text"]').each(function(){
this.value = replace(",",",");
});
}
</script>
Would love help to get it working. Sorry I am totally Javascript-inept.
You can do this to split at the
commasthen rejoin with","Pure javascript http://jsfiddle.net/mQrLS/3/
As @Radu mentioned the replace with regex does perform faster