tim_ver Posted March 26, 2007 Share Posted March 26, 2007 I have this script now for one of my forms and when people use it they are putting in n/a or bobo.bob.com for email address so when I get the form I get in the from spot the hositing companies email and not the users name or email, how do I fix this so they must use a valid email format, and it puts what the use in the email line in the from spot? Code: <script type="text/javascript" language="javascript" charset="utf-8"> // <![CDATA[ function Check() { error = ''; if(document.frm.Email.value=='') { error += 'Email is required\n'; } if(document.frm.Contact_Name.value=='') { error += 'Contact name is required\n'; } if(document.frm.Contact_Phone.value=='') { error += 'Phone number is required\n'; } if(error!=''){ window.alert(error); return false; } return true; } // ]]> </script> Thanks Link to comment https://forums.phpfreaks.com/topic/44276-email-form-issue-not-enforcing-it/ Share on other sites More sharing options...
tim_ver Posted March 26, 2007 Author Share Posted March 26, 2007 I did add this to it but not working. I need it to force users to enter a vaild email address in the email box. <script type="text/javascript" language="javascript" charset="utf-8"> // <![CDATA[ { error = ''; function Check() function validate_Email(field,alerttxt) { with (field) { apos=value.indexOf("@") dotpos=value.lastIndexOf(".") if (apos<1||dotpos-apos<2) {alert(alerttxt);return false} else {return true} if(document.frm.Email.value=='') { error += 'Email is required\n'; } if(document.frm.Contact_Name.value=='') { error += 'Contact name is required\n'; } if(document.frm.Contact_Phone.value=='') { error += 'Phone number is required\n'; } if(error!=''){ window.alert(error); return false; } return true; } // ]]> </script> Link to comment https://forums.phpfreaks.com/topic/44276-email-form-issue-not-enforcing-it/#findComment-215122 Share on other sites More sharing options...
BlackenedSky Posted March 28, 2007 Share Posted March 28, 2007 http://www.devshed.com/c/a/JavaScript/Understanding-the-JavaScript-RegExp-Object/ use a RegExp to match the pattern for an email. See that link for a tutorial Link to comment https://forums.phpfreaks.com/topic/44276-email-form-issue-not-enforcing-it/#findComment-217028 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.