Results 1 to 3 of 3

Thread: Possibly Simple Question to be answered

  1. #1

    Thread Starter
    Member
    Join Date
    Jan 2000
    Posts
    63

    Question

    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

  2. #2
    Guest
    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:

    Code:
    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 " ".

  3. #3

    Thread Starter
    Member
    Join Date
    Jan 2000
    Posts
    63
    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width