Forum Moderators: open
want to exclude empty textfields in mail that i recieve when user submits a form to me...
in the form it is allowed to leave empty textfields, and it should be..
so -->> i don't want the empty ones listed in my mail.
suggestions? examples? good hints?
anything, please! (i believe i've browsed through every page on the net...)
If you want to exclude emply fields, you will need to alter your mailing script (probably written in Perl, PHP or similar server-side language).
you could validate the form :
<form .... onsubmit="return validateForm(this);" ...>
function validateForm(oFrm){
var fld;
for(x=oFrm.elements.length;x==0;x--){
fld =oFrm.elements[x];
if(fld.value ==""){
oFrm.removeChild(fld);
}
}
return true;
}
havent checked this but should work..(he says)
a bit of a hack, but sounds like what u want.
and of course wont work with a non DOM browser.
i know that there is no return false for failed validation, but mbe u can add that urself.
HTH
nat
[edited by: natty at 11:42 am (utc) on July 28, 2004]
<form name="carlsberg" method="post" onsubmit="return validateForm(this)" action="mailto:se.sommar33fbg@carlsberg.se">
<input type="text" name="ol" value=""></input><p>
<input type="text" name="vin" value=""></input><p>
<input type="text" name="sprit" value=""></input><p>
<input type="submit">Bekräfta</input>
</form>
how on earth would implement the code given
although this doesnt check to see if nothing has been entered.. which may be worth doing ;)
<html>
<head>
<script type="text/javascript">
function validateForm(frm){
for(var x=frm.elements.length-1;x>-1;x--){
if(frm.elements[x].type =="text"){
(frm.elements[x].value=="")? frm.removeChild(frm.elements[x]):null;
}
}
}
</script>
</head>
<body>
<form name="f1" onsubmit="validateForm(this);" method="post" action="mailto:someone@emailgoeshere.com">
<input type="text" name="ol" value=""><br>
<input type="text" name="vin" value=""><br>
<input type="text" name="sprit" value=""><br>
<input type="submit" value="send it"><br>
</form>
</body>
</html>
so what i'm asking, is... is there a way to split up the same form in differnet coulumn and still run through them with the same funtion as i have now?...
(check the funtion in previous post)....
i've tried as hard as i can, but since i suck at it i've come up with no solution... what to do...