PDA

View Full Version : Sumit button verification



Gazzab
07-29-2012, 12:27 PM
Hi,

I'm trying to edit a submit button so when clicked and my fields below are all met the message returned is something like "Verification successful - Form sent"

My apologies for being so ignorant, I really don't know how to write .js, I believe the code below is relevant and I imagine its what requires editing?


submitRequest : function (event, formName, containerId) {
var postData = [],
re = /([0-9a-zA-Z\.\-\_]+)@([0-9a-zA-Z\.\-\_]+)\.([0-9a-zA-Z\.\-\_]+)/,
msg = '',
name = document.forms[formName].name.value,
email = document.forms[formName].email.value,
verification = document.forms[formName].verification.value;

if (name == '') {
msg += '\n Name is required';
}

if (email == '') {
msg += '\n E-Mail is required';
}

if (email != '' && email.match(re) == null) {
msg += '\n E-Mail is invalid';
}

if (verification == '') {
msg += '\n Verification is required';
}

if (msg != '') {
alert('Please note that:' + msg);
} else {
postData.push('date_from=' + document.forms[formName].from_year.value + '-' + document.forms[formName].from_month.value + '-' + document.forms[formName].from_day.value);
postData.push('date_to=' + document.forms[formName].to_year.value + '-' + document.forms[formName].to_month.value + '-' + document.forms[formName].to_day.value);
postData.push('listing_id=' + document.forms[formName].listing_id.value);
postData.push('name=' + encodeURIComponent(name));
postData.push('email=' + encodeURIComponent(email));
postData.push('phone=' + encodeURIComponent(document.forms[formName].phone.value));
postData.push('notes=' + encodeURIComponent(document.forms[formName].notes.value));
postData.push('verification=' + encodeURIComponent(document.forms[formName].verification.value));

Many Thanks in advance for any assistance...:)