You are doing this sort of right:
Code:
var str = document.forms.Form1.header.value;
str.replace(/;/, '');
It should probably be:
Code:
str.replace(/;/gm
, '');
The gm
simply means to replace this globally on every line. Very old browsers will barf on the m (multi-line) part though. So, if it is only all one long line, just use g
.
However, even with that enhancement, simply declaring:
Code:
str.replace(/;/gm, '');
doesn't really do anything. It does strip ;
from str
, but it doesn't change str
, and it doesn't set anything to the stripped value of str
.
So you might want to do:
Code:
function checkform(){
if(document.forms.Form1.header && document.forms.Form1.header.value =='')
{
alert('You have not entered an email header. Please try again.');
return false;
}
else {
var str = document.forms.Form1.header.value;
document.forms.Form1.header.value = str.replace(/;/gm, '');
return true;
}
}
This will be effective, as long as it executes before ;
can cause an error.
Bookmarks