email format jquery

jQuery(‘.ad_agent_contact_form .send_email_agent_btn’).click(function(){
var no_error = 1;
function validEmail(v) {
var r = new RegExp(“[a-z0-9!#$%&’*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&’*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?”);
return (v.match(r) == null) ? false : true;
}
jQuery(‘.ad_agent_contact_form .required_field’).css(‘border’,’1px solid #E7E7E7′);
jQuery(‘.ad_agent_contact_form .required_field’).each(function(){
var this_val = jQuery(this).val();
if(this_val==”” || this_val ==” “){
jQuery(this).css(‘border’,’1px solid #f00′);
no_error = 0;
jQuery(‘.ad_agent_contact_form .form_message_agent’).html(‘

Please fill all required fields

‘);
}
});
if(no_error==1){
var usr_name = jQuery(‘.ad_agent_contact_form #name_contacti’).val();
var usr_email = jQuery(‘.ad_agent_contact_form #email_contacti’).val();
var usr_phone = jQuery(‘.ad_agent_contact_form #phone_contacti’).val();
var usr_subj = jQuery(‘.ad_agent_contact_form #subject_contacti’).val();
var usr_msg = jQuery(‘.ad_agent_contact_form #message_contacti’).val();
var usr_ad_contacti = jQuery(‘.ad_agent_contact_form #usr_ad_contacti’).val();
if (!validEmail(usr_email)) {
jQuery(‘.ad_agent_contact_form .form_message_agent’).html(‘

Please enter proper email format

‘);
}
else{
jQuery(‘.ad_agent_contact_form .form_message_agent’).html(”);
jQuery.get(Drupal.settings.basePath+’agent_contact_email?usr_name=’+usr_name+’&usr_email=’+usr_email+’&usr_phone=’+usr_phone+’&usr_subj=’+usr_subj+’&usr_msg=’+usr_msg+’&usr_ad_contacti=’+usr_ad_contacti, function(data) {
jQuery(‘.ad_agent_contact_form .form_message_agent’).html(data);
});
}
}

});

Was this article helpful?

Related Articles