Form help

owas

Free Member
Jan 3, 2010
1,422
256
Hi,
this is the info for a form submitted via my website. When the user submits an email, I want a message to also go to the submitted email address with a link.
I have been trying lots of different ideas, and even auto reply form my email address, but that wont work.
If anyone has any suggestions or code that will sort this, I would hugely appreciate the help.

<script src="js/superfish.js"></script>


<script>
$(function(){
$('#form1').forms({ownerEmail:'[email protected]'});
});
</script>


<form id="form1">
<div class="success"> Thank you for joining!<br>
<strong>We will be in touch soon.</strong> </div>
<fieldset>
<label class="email">
<input type="text" value="Enter Your Email">
<span class="error">*This is not a valid email address.</span> <span class="empty">*This field is required.</span> </label>
<div class="buttons"><a class="link1" data-type="reset">Reset</a><a class="link1" data-type="submit">Submit</a></div>
</fieldset>
</form>


(function($){
$.fn.extend({
forms:function(opt){
if(opt===undefined)
opt={}
this.each(function(){
var th=$(this),
data=th.data('forms'),
_={
errorCl:'error',
emptyCl:'empty',
invalidCl:'invalid',
successCl:'success',
successShow:'4000',
mailHandlerURL:'bin/MailHandler.php',
ownerEmail:'[email protected]',
stripHTML:true,
smtpMailServer:'localhost',
targets:'input,textarea',
controls:'a[data-type=reset],a[data-type=submit]',
validate:true,
rx:{
".name":{rx:/^[a-zA-Z'][a-zA-Z-' ]+[a-zA-Z']?$/,target:'input'},
".email":{rx:/^(("[\w-\s]+")|([\w-]+(?:\.[\w-]+)*)|("[\w-\s]+")([\w-]+(?:\.[\w-]+)*))(@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$)|(@\[?((25[0-5]\.|2[0-4][0-9]\.|1[0-9]{2}\.|[0-9]{1,2}\.))((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\.){2}(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\]?$)/i,target:'input'},
".phone":{rx:/^\+?(\d[\d\-\+\(\) ]{5,}\d$)/,target:'input'},
".message":{rx:/.{20}/,target:'textarea'}
},
preFu:function(){
_.labels.each(function(){
var label=$(this),
inp=$(_.targets,this),
defVal=inp.val()
label.data({defVal:defVal})
inp
.bind('focus',function(){
if(inp.val()==defVal)
inp.val('')
})
.bind('blur',function(){
if(!inp.val())
inp.val(defVal)
else
(_.isValid(label)
?_.showErrorFu(label)
:_.hideErrorFu(label)),
(_.isEmpty(label)
?_.showEmptyFu(label)
:_.hideEmptyFu(label))
})
label.find('.'+_.errorCl+',.'+_.emptyCl).css({display:'block'}).hide()
})
_.success=$('.'+_.successCl,_.form).hide()
},
isValid:function(el){
var ret=true
if(_.isEmpty(el))
ret=false,
el.addClass(_.invalidCl)
else
$.each(_.rx,function(k,d){
if(el.is(k))
d.rx.test(el.find(d.target).val())
?(el.removeClass(_.invalidCl),ret=false)
:el.addClass(_.invalidCl)
})
return ret
},
isEmpty:function(el){
var ret=false,
field=el.find(_.targets).val()
if(field==''||field==el.data('defVal'))
ret=true
return ret
},
validateFu:function(){
_.labels.each(function(){
var th=$(this)
_.isEmpty(th)
?_.showEmptyFu(th)
:_.hideEmptyFu(th)
_.isValid(th)
?_.showErrorFu(th)
:_.hideErrorFu(th)
})
},
submitFu:function(){
_.validateFu()
if(!_.form.has('.'+_.invalidCl).length)
$.ajax({
type: "POST",
url:_.mailHandlerURL,
data:{
name:$('.name input',_.form).val(),
email:$('.email input',_.form).val(),
phone:$('.phone input',_.form).val()||'nope',
message:$('.message textarea',_.form).val(),
owner_email:_.ownerEmail,
stripHTML:_.stripHTML
},
success: function(){
_.showFu()
}
})
},
showFu:function(){
_.success.slideDown(function(){
setTimeout(function(){
_.success.slideUp()
_.form.trigger('reset')
},_.successShow)
})
},
controlsFu:function(){
$(_.controls,_.form).each(function(){
var th=$(this)
th
.bind('click',function(){
_.form.trigger(th.data('type'))
return false
})
})
},
showErrorFu:function(label){
label.find('.'+_.errorCl).slideDown()
},
hideErrorFu:function(label){
label.find('.'+_.errorCl).slideUp()
},
showEmptyFu:function(label){
label.find('.'+_.emptyCl).slideDown()
_.hideErrorFu(label)
},
hideEmptyFu:function(label){
label.find('.'+_.emptyCl).slideUp()
},
init:function(){
_.form=this
_.labels=$('label',_.form)

_.preFu()

_.controlsFu()

_.form
.bind('submit',function(){
if(_.validate)
_.submitFu()
else
_.form[0].submit()
return false
})
.bind('reset',function(){
_.labels.removeClass(_.invalidCl)
_.labels.each(function(){
var th=$(this)
_.hideErrorFu(th)
_.hideEmptyFu(th)
})
})
}
}
if(!data)
(typeof opt=='object'?$.extend(_,opt):_).init.call(th),
th.data({cScroll:_}),
data=_
else
_=typeof opt=='object'?$.extend(data,opt):data
})
return this
}
})
})(jQuery)
 
You should be handling all your form contact magic (including / especially field cleansing) server side. Also, your markup on the form isn't great. You need to get rid of the fieldsets, attach your labels to a field with for="", use inline emphasis correctly (get rid of strong), and use actual html buttons for submitting the form.
 
Upvote 0
I know its not quite right, and I still have changes to make, but is there a line I can add somewhere so that the visitor who submits the email gets a copy?
 
Upvote 0
This would need the PHP script and the Javascript changing to be able to send a CC to another person. The script submits the data here:

submitFu:function(){
_.validateFu()
if(!_.form.has('.'+_.invalidCl).length)
$.ajax({
type: "POST",
url:_.mailHandlerURL,
data:{
name:$('.name input',_.form).val(),
email:$('.email input',_.form).val(),
phone:$('.phone input',_.form).val()||'nope',
message:$('.message textarea',_.form).val(),
owner_email:_.ownerEmail,
stripHTML:_.stripHTML
},
I really would advise you to look at an alternative - it's bad coding and very insecure.

Steve
 
Upvote 0
It's a template monster temp, that I have alterd, heard these aren't the best.
If your able to sort this could you pm me the cost.
And I will send you the site info,
Ta
 
Upvote 0

Latest Articles