Email Validation in coldfusion

 <cfif isDefined("form.MailTo")>
    <cfset valid = REFind("^[a-zA-Z][\w\.-]*[a-zA-Z0-9]@[a-zA-Z][\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]$", Trim(form.MailTo), 1) gt 0>
    <cfif (form.MailTo NEQ 'Enter an email address') AND (form.MailTo NEQ '') AND (valid EQ 'YES')  >  
       <cfmail to = "#form.MailTo#" from = "xyz@mail.com" subject = "test"  type="text/html" >
                  test
            </cfmail>
          <div ><h2>Email sent successfully!</h2><p>to:  <cfoutput>#form.MailTo#</cfoutput></p></div>
    <cfelse>
        <div ><h2>Email not sent. No valid email address supplied.</h2></div>
    </cfif>
</cfif>



<form action = " " method="post" >
        <h2>Email to:</h2> <input type = "Text" name = "MailTo" value="Enter an email address"  onFocus="if(this.value == 'Enter an email address') { this.value = ''; }" onBlur="if(this.value == '') { this.value = 'Enter an email address'; }" />
        <input type="submit" value="Send" name="submit"  />
    </form>

Comments

Popular posts from this blog

how to add new line in google form questions | Fix for next line issue in google form questions

How to add new line in dropdown type question in google forms