Javascript Validator
sorry, again with this problem, but it's urgent this time and I haven't got my programmer friend who put it together for me to help so i'm stumped!
This form I have has a validator and that part is all working, so that's good, but while I was testing I didn't have it actually submitting and now that I've added the action and the email address to send it to I realise it doesn't even send..
I think it's actually lacking anythign that tells it to send. im using a regular button instead of a submit button. i just need to know where to put the 'submit' function and how!
here is the HTML for the form:
here is the javascript
all that modal=true stuff is to show or hide the div in which the form is in, it only shows if the page is directed from a certain address, and it only disappears if the form is validated.
Can anyone see where I need to insert something to make the form actually SEND to the email adress?
All it seems to do onclick is check to see if it is validated..
This form I have has a validator and that part is all working, so that's good, but while I was testing I didn't have it actually submitting and now that I've added the action and the email address to send it to I realise it doesn't even send..
I think it's actually lacking anythign that tells it to send. im using a regular button instead of a submit button. i just need to know where to put the 'submit' function and how!
here is the HTML for the form:
<form id="form1" name="form1" method="post" action="http://mailgate.server-mail.com/cgi-bin/mailgate">
<input type=hidden name="recipient" value="mail@domain.com">
<input type=hidden name="subject" value="Radio Survey">
<input type="radio" name="Group1" value="3AW" />3AW<br>
<input type="radio" name="Group1" value="2GB" /> 2GB <br>
<input type="radio" name="Group1" value="None" />N/A, I didn't hear your ad</p>
<input name="button" type="button" onclick="(doValidate() ? hideModal() : showModal());" value="Submit">
</form>
here is the javascript
<script language="javascript" type="text/javascript">
//setup initial modal properties
var modal = document.getElementById('modalWdw');
function showModal()
{
modal.style.display='block';
}
function hideModal()
{
modal.style.display='none';
return true;
}
function doValidate()
{
var group1Checked;
for (var i=0; i<document.getElementsByName('Group1').length; i++)
{
if (document.getElementsByName('Group1')[i].checked)
{
group1Checked = document.getElementsByName('Group1')[i].value;
}
}
if(!group1Checked)
{ //if group1Checked does not equal null
alert("You did not make a selection.")
}
else
{
alert('Thankyou, your selection was: ' + group1Checked);
return true;
}
}
showModal();
function checkOnLoad()
//essentially, this function just scans the current page url and looks
// for the querystring (after the '?'), then checks to see if "modal=true"
// was included as a querystring key-value pair
{
var arr = window.location.href.split(/\?/g);
if (arr.length >= 2)
{
var vals = arr[1].split(/=/g);
if (vals.length >= 2)
{
for (var i = 0; i<vals.length; i++)
{
if (vals[i] == 'modal')
{
if (vals[i+1] == 'true')
{
return true;
}
}
}
}
}
else
{
//no modal
hideModal();
}
return false;
}
(checkOnLoad() ? showModal() : hideModal());
</script>
all that modal=true stuff is to show or hide the div in which the form is in, it only shows if the page is directed from a certain address, and it only disappears if the form is validated.
Can anyone see where I need to insert something to make the form actually SEND to the email adress?
All it seems to do onclick is check to see if it is validated..
