Hi guys, I need help, I'm new to scripting and I've been trying to figure out how to do number 1. I've got the error message which checks if the "@" symbol is at the beginning of the input, but I don't know how to do it when the user puts the "@" at the end.
1. Check the "@" symbol is not at the beginning or end of the input, else display a specific message.
2. Check there is a period to the right of @
check that there is enough room for at least a one
character domain name and at least a two character top
level domain between the @, the period, and the end of
the email. The minimum size for the complete host name
would look like this: ...@d.ca
3. The last period must be at least two positions to the right of @ and the last period must be at least 2 positions from the end (think length) of the address. The InStrRev()
function is useful to find the last period.
I'm trying to work on 2 and 3, chances are I'm going to ask help for those too. Anyway, that's just the part I need help on. It's just about basic VB functions. We're only using InStr, InStrRev, Len.
Thanks for any help!
VB script email validation. Simple VB functions.io
Forum rules
Do not post any licensing information in this forum.
Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
Do not post any licensing information in this forum.
Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
VB script email validation. Simple VB functions.io
Regex is a vbscript function/class that is well documented.
http://msdn.microsoft.com/en-us/library/ms974570.aspx
This is how we do things in the real world. If you professor doesn't know about this then you need to get a different school/professor.
Of course it may be that your professor wants you to learns something so he is giving you a limited challenge to make you think your way through the instructions.
Start by actually trying to write the script then ask a specific question when you get stuck.
We will not do your homework for you.
http://msdn.microsoft.com/en-us/library/ms974570.aspx
This is how we do things in the real world. If you professor doesn't know about this then you need to get a different school/professor.
Of course it may be that your professor wants you to learns something so he is giving you a limited challenge to make you think your way through the instructions.
Start by actually trying to write the script then ask a specific question when you get stuck.
We will not do your homework for you.
VB script email validation. Simple VB functions.io
No, he probably does know this RegEx script, but I`m only on my first year and hes only teaching us the basics of writing a VBscript.
And I do have a script I`m stuck on how to get an error message when the "@" sign is placed at the end of the input box.
And I do have a script I`m stuck on how to get an error message when the "@" sign is placed at the end of the input box.
Code: Select all
<% Option Explicit
Const TITLE = ""
Const SCRIPT_DESC = "Bit to Bytes conversion."
Const BR = "<br>"
Const SUBMIT_BUTTON = "Submit"
' input/output variables
Dim submit, conversionCode, inputValue, email
' output variables
Dim message, Error1, Error2, Error3, total, text
' work variables
Dim isInputValid, posAT, posDot, atSearch
' assign initial value of validation flag
isInputValid = True
' retrieve submit button from HTML FORM
submit = Request.Form("submit")
conversionCode = Ucase(Trim(Request.Form("conversionCode")))
inputValue = Request.Form("inputValue")
email = Lcase(Trim(Request.Form("email")))
posAT = InStr(email, "@")
posDot = InStr(email, ".")
' check if script requested by URL or FORM was submitted by user
IF submit <> "" THEN 'FORM was submitted by user.
' this checks the user's input field 1 if input is valid. If a problem is found, set isInputValid = FALSE and tell user about this particular input field's problem and how to correct it.
IF conversionCode = "" THEN 'no input
isInputValid = False 'tell the program there was a problem
Error1 = "Please enter a code." 'tell user how to fix the problem
ELSEIF conversionCode <> "AB" AND conversionCode <> "BB" THEN 'unknown conversion code
isInputValid = False 'tell the program there was a problem
Error1 = "Please enter the following codes: AB or BB" 'tell the user how to fix the problem
END IF
' this IF statement checks if the second input field is valid. If a problem is found, set isInputValid = FALSE and tell the user about the particular problem and how to correct it.
IF inputValue = "" THEN 'no input
isInputValid = False
Error2 = "Please enter a number to convert."
ELSEIF isNumeric(inputValue)=False THEN 'checks if the input is a number
isInputValid = False
Error2 = "Please input a numeric value."
ELSEIF Ccur(inputValue) < 0 THEN 'compare after converting to numeric.
isInputValid = False
Error2 = "This must be greater than zero."
END IF
IF Len(email) = 0 THEN 'no email address provided
isInputValid = False
Error3 = "Please type in your email address."
ELSEIF InStr(email, "@") = 0 THEN
isInputValid = False
Error3 = "No '@' sign found."
ELSEIF posAT = 1 THEN
isInputValid = False
Error3 = "The '@' sign cannot be placed at the begginning or at the end of the email."
END IF
END IF ' submit <> "" ' FORM was submitted by user
%>
VB script email validation. Simple VB functions.io
Hint. Instruction1 says:
1. Check the "@" symbol is not at the beginning or end of the input, else display a specific message.
Using InStr test for zero will prove what? What does InStr return?
What is true if the @ is at the end of the string? What function tells us about the end of the string and how would we use that to test?
1. Check the "@" symbol is not at the beginning or end of the input, else display a specific message.
Using InStr test for zero will prove what? What does InStr return?
What is true if the @ is at the end of the string? What function tells us about the end of the string and how would we use that to test?