PDA

Click to See Complete Forum and Search --> : Possibly Simple Question to be answered


HakanAzaklioglu
Feb 6th, 2001, 03:34 PM
First Question
==================
How easy is it to pop up a message box with vbscript for the soul purpose of creating a form validation script

For example they don't put there email address in. A message box pops up and says Please enter your email address.



Second Question
==================
Is there anyway for me to put a sentence in a text box on a webpage and collect the first letter of each word??

Kind Regards,
Hakan

Feb 6th, 2001, 04:23 PM
MSG box won't work, you want to either open another window, or repost the form data.

Here is some code from a script I wrote that does what you are talking about. It looks for required fields, and if any of the required fields are empty, it reposts the data that was entered, and provides a detailed error message about the missing data:



addFN = Trim(Request.Form ("FirstName"))
addLN = Trim(Request("LastName"))
addPH = Trim(Request("Phone"))
addFX = Trim(Request("Fax"))
addEM = Trim(Request("E-Mail"))

If addFN = "" Then
strError = "First Name"
End If
If addLN = "" Then
If strError <> "" then strError = strError & ", "
strError = strError & "Last Name"
End If
End If
If addPH = "" Then
If strError <> "" then strError = strError & ", "
strError = strError & "Phone Number"
End If
End If
If addEM = "" Then
If strError <> "" then strError = strError & ", "
strError = strError & "E-Mail Address"
End If
End If

If strError = "" Then
'add the data to the database
Else
strMessage = "The following required fields do not contain data: " & strError
blnRepost = true
End If

<INPUT type="text" size=25 name=FirstName <%IF blnRepost = true then%>value=<%=addFN%><% end if%>>

'''then goes on and on for the other fields



This all has to be put into a form

As far as the sentence goes, you just use normal vb string manipulation code:

search instr for " " and then take the first char after " ".

HakanAzaklioglu
Feb 7th, 2001, 07:40 AM
Thanks for bursting my bubble on the first one :)

As far as the second one goes... The "instr" command is what I should be looking up right?

I need to do this because I have employees at my work give me a 6 word sentence and from the 6 words I use the first letter of each word the derive a 6 digit password... The command you have suggested will be able to do this correct?

Kind Regards,
Hakan