The Forum has been Updated
The code has been upgraded to the latest .NET core version. Please check instructions in the Community Announcements about migrating your account.
I have a page where the user enters an email address. What code would I use to make sure the email address is in a valid format? I don't need to verify it. I just want to make sure they enter something like abc@abc.com. If they don't then I want them to receive an error about the email not being valid and to go back and enter a valid one.<
نوشته شده در
http://www.regular-expressions.info/email.html<
نوشته شده در
I seem to remember there was a ChkEMail function (or something similar) in inc_func_common.asp. It would be a good place to start...<
نوشته شده در
AnonJr: I have had a look through inc_func_common and can not see an email validity check routine. Like you say, I am sure there is a routine, somewhere within the forum, to meet leatherlips requirement. Any further ideas please..<
نوشته شده در
Posted sometime ago as a security fix replacement for an existing function in inc_func_member.asp:
<
Code:
function EmailField(fTestString)
set regEx = New RegExp
regEx.Global = true
regEx.IgnoreCase = true
regEx.Pattern = "^[A-Z0-9._%-]+@(?:[A-Z0-9-]+\.)+[A-Z]{2,4}$"
retVal = regEx.Test(fTestString)
set regEx = nothing
if Not retVal Then
EmailField = 0
Else
EmailField = 1
end if
end function
نوشته شده در
thank u ruirib<
نوشته شده در
Is there an easy way to link this function Emailfield to my input field:
response.write " <input type=""text"" style=""background-color:#F5FBF1"" name=""frommail"" size=""50"">" & vbNewLine
I have added the function to my inc_func_common and can not see how to tie the functionality together with appropriate error message to be displayed - if a user inputs a wrong email string format
The code I have on the form preview is:
frommail = trim(chkString(request.form("frommail"),"SQLString")) if frommail ="" then strError = strError & "Please enter your email address!<br>" 'checking for blank email field
if (InStr(Request("tomail"), "@") = 0 or InStr(Request("frommail"), "@") = 0) then strError = strError & "Enter an e-mail address in the form username@domain.co.uk<br></font>"
But is a user puts an email in this format humbug@xmas the routine passes, (that is the code I have)
Thank you andy
<
response.write " <input type=""text"" style=""background-color:#F5FBF1"" name=""frommail"" size=""50"">" & vbNewLine
I have added the function to my inc_func_common and can not see how to tie the functionality together with appropriate error message to be displayed - if a user inputs a wrong email string format
The code I have on the form preview is:
frommail = trim(chkString(request.form("frommail"),"SQLString")) if frommail ="" then strError = strError & "Please enter your email address!<br>" 'checking for blank email field
if (InStr(Request("tomail"), "@") = 0 or InStr(Request("frommail"), "@") = 0) then strError = strError & "Enter an e-mail address in the form username@domain.co.uk<br></font>"
But is a user puts an email in this format humbug@xmas the routine passes, (that is the code I have)
Thank you andy
<
نوشته شده در
The function should replace the existing EmailField function in inc_func_member.asp so you will also need to include inc_func_member.asp
you would then use it like so
if EmailField(frommail) = 1 then
'we passed so do stuff :)
else
'we failed so error
end if<
you would then use it like so
if EmailField(frommail) = 1 then
'we passed so do stuff :)
else
'we failed so error
end if<
نوشته شده در
Thank u HuwR<
نوشته شده در
I currently do not have access to my forum files, but following Huwrs input, would this work:
if EmailField(frommail) = 0 then strError = strError & "Enter an e-mail address in the form username@domain.co.uk<br></font>"
... .. end if (later)
I have gone for the =0 as all the other error messages have a link underneath to return to input form.<
if EmailField(frommail) = 0 then strError = strError & "Enter an e-mail address in the form username@domain.co.uk<br></font>"
... .. end if (later)
I have gone for the =0 as all the other error messages have a link underneath to return to input form.<
نوشته شده در
yes, that should be fine.<
Email Member
Message Member
Post Moderation
بارگزاری فایل
If you're having problems uploading, try choosing a smaller image.
پیشنمایش مطلب
Send Topic
Loading...