/    Sign up×
Community /Pin to ProfileBookmark

How to set the recipient address to contact form?

Hello I am trying trouble setting up the recipient address to my contact form. I would appreciate if you can help me out! Thanks.

I am assuming you set up the recipient adders in the .js code so here I am sharing it :

[code]

// contact
var error = true;

function addLoading()
{
$(‘#sendbutton’).val(‘wait…’).attr(‘disabled’, true);
}

function removeLoading()
{
$(‘#sendbutton’).val(‘Send’).attr(‘disabled’, false);
}

function addError(msg, e)
{
error = true;
$(e).addClass(‘error’);
$(‘#usermessagea’).html(msg);
}

function removeError(e)
{
error = false;
$(‘#usermessagea’).html(”);
$(e).removeClass(‘error’);
}

$(‘#email’).blur(function(){
var expr = /^[_a-z0-9+-]+(.[_a-z0-9+-]+)*@[a-z0-9-]+(.[a-z0-9-]+)+$/;

if( !expr.test( $(this).val() ) )
addError(‘<p class=”error”>Email is incorrect!</p>’, this);
else
removeError(this);
});

$(‘#form-contact .required’).blur(function(){
if( $(this).val() == ” )
addError(‘<p class=”error”>One or more field required are empty!</p>’, this);
else
removeError(this);
});

$(‘#form-contact’).submit(function(){
if( !error )
{
var datastring = ”;

$(‘#form-contact input, #form-contact select, #form-contact textarea’).each(function(){
datastring = datastring + $(this).attr(‘name’) + “=” + $(this).val() + ‘&’;
});

$(‘#usermessagea’).html(”);
addLoading();

$.post( $(this).attr(‘action’), datastring, function(response){
$(‘#usermessagea’).html(response);
removeLoading();
});
}
else
addError(‘<p class=”error”>One or more field aren’t filled correctly!</p>’, this);

return false;
});
});

[/code]

to post a comment
JavaScript

1 Comments(s)

Copy linkTweet thisAlerts:
@irf2kMar 31.2011 — I'm not sure I understand your question

The code you have posted seems to be using jquery to VALIDATE a form.

I'm assuming from the code that the user would enter their email address, select something from a dropdown and enter a message.

But you need to know that all javascript can do is VALIDATE, i.e. make sure that the user enters the fields. To actually SEND the email to someone (the recipient) you would need to use a SERVER side scripting language (like php) and perhaps AJAX if you wanted to do it all from one page.

Perhaps if you posted a link to your full code, or where you got this code from?
×

Success!

Help @jandr27 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.19,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...