PDA

View Full Version : E-mail form and CR/LF?


rfchmbrs
11-02-2003, 12:14 PM
Below is the Javascript portion of a form for sending an e-mail. Every thing works except the CR/LF. I have it set to \n\r which is fine in the Alert call but does not CR or LF in the body of the received e-mail.

I've tried \n \r %0A % 0D ......

HELP please.
RON C

<script type="text/javascript" language="JavaScript">
var is_valid = true;
var email_url = "xxx@yyy.edu";
var config = "";
var cr = "\n\r";
var diag = 0;

// -----
// check that each field is correct
// -----
function IsNotEmpty(FieldValue, Alert)
{
if(diag != 0) alert(FieldValue);
if(FieldValue == "")
{
if(Alert != "") alert(Alert);
return false;
}
return true;
}
// -----
//validate all fields when user clicks submit
// -----
function validate()
{
is_valid = true;
if(diag == 0)
{
is_valid = true;

if(!IsNotEmpty(document.gg_form1.name.value, 'Please enter your Name.'))
{is_valid = false; return false;}

if(!IsNotEmpty(document.gg_form1.address.value, 'Please enter your address.'))
{is_valid = false; return false;}

if(!IsNotEmpty(document.gg_form1.email.value, 'Please enter your E-mail address.'))
{is_valid = false; return false;}

if(!IsNotEmpty(document.gg_form1.years.value, 'Please enter your membership years.'))
{is_valid = false; return false;}
}
// -----
// -----
config = "mailto:" + email_url;
config += "?subject=Information Update";
config += "&body=";
config += cr + "NAME" + cr + document.gg_form1.name.value;
config += cr + "ADDRESS" + cr + document.gg_form1.address.value;
config += cr + "EMAIL ADDRESS" + cr + document.gg_form1.email.value;
config += cr + "YEARS" + cr + document.gg_form1.years.value;
config += cr + "OFFICES HELD" + cr + document.gg_form1.offices.value;
config += cr + "COMMENTS" + cr + document.gg_form1.comments.value;
if(diag == 1) alert(config);
// -----
document.gg_form1.method = "POST";
document.gg_form1.action = config;
document.gg_form1.submit();

return true;
}
</script>

ucm
11-18-2003, 10:30 AM
if the email is being viewed by the receiving party in HTML format then the /n/r will have no effect, instead for HTML based e-mails, you'd need to use "<br>"

if you need for both plain text AND for HTML based e-mail to be supported, i'd recommend putting a line at the top just before the information saying "If you use HTML e-mail viewing then scroll to the second paragraph below.\n\r<br>"

then first put your paragraph just they you have it and then put the same thing again only with "<br>" instead of \n\r

of course an easier way would be to set the e-mail client that will be viewing this e-mail to either "plain text" or you could change it all the way around and just add the "<br>" tags to the very begining of each line, of course doing that would make the "<br>" visible on plain text e-mail readers...