Results 1 to 4 of 4

Thread: Validate text boxes with vbscript

  1. #1

    Thread Starter
    Frenzied Member longwolf's Avatar
    Join Date
    Oct 2002
    Posts
    1,343

    Validate text boxes with vbscript

    I'm trying to make a 'Create User Account' page with asp and vb script.
    I want to validate the text box entries before passing to the next page.
    I searched the forums and tried to use the most promissing code I could find, but it's not working.
    It just goes to the next page as soon as you click the submit button.

    Can anyone help?

    Code:
    <HTML>
    <HEAD>
    <title>New Account</title>
    
    <SCRIPT Language="vbscript">
    function Validate
    
    Msgbox "Just a test pop-up !!!"
       If (document.form.UserName.value = "" or _
            document.form.Password.value = ""  or _
            document.form.Confirm.value = "" ) Then
           Msgbox "Fill in text box !!!"
           Validate = false
       Else
           Validate = true
       End If
    end function
    </SCRIPT>
    
    </HEAD>
    
    <BODY>
    
    <CENTER>
    <BR>
    <BR>
    
    <FORM NAME="Logn" METHOD="post" ACTION="index.shtml">
    <TABLE BORDER="1" CELLSPACING="0" CELLPADDING="7" WIDTH="250" BGCOLOR="#6B656B">
      <TR>
        <TD>
    	<H3>Create a New Account</H3>
    
    	&nbsp;User Name:<BR>
    	<INPUT TYPE="text" NAME="UserName" SIZE="30">
    	<BR>
    	<BR>
    
    	&nbsp;Password:<BR>
    	<INPUT TYPE="text" NAME="Password" SIZE="30">
    	<BR>
    	<BR>
    
    	&nbsp;Confirm Password:<BR>
    	<INPUT TYPE="text" NAME="Confirm" SIZE="30">
    	<BR>
    	<BR>
    	<CENTER>
    	<INPUT TYPE="Submit" NAME="Apply" VALUE="Submit" OnSubmit="vbscript: Validate">
    </CENTER>
        </TD>
      </TR>
    </TABLE>
    </FORM></CENTER>
    
    </BODY>
    </HTML>

  2. #2

    Thread Starter
    Frenzied Member longwolf's Avatar
    Join Date
    Oct 2002
    Posts
    1,343

    Re: Validate text boxes with vbscript

    Ok, I've gotten it to call the function by moving the 'OnSubmit' like this:
    Code:
    <FORM NAME="Logn" METHOD="post" OnSubmit="vbscript: Validate" ACTION="index.shtml">
    <TABLE BORDER="1" CELLSPACING="0" CELLPADDING="7" WIDTH="250" BGCOLOR="#6B656B">
      <TR>
        <TD>
    	<H3>Create a New Account</H3>
    
    	&nbsp;User Name:<BR>
    	<INPUT TYPE="text" '...........
    
    	<BR>
    	<CENTER>
    	<INPUT TYPE="Submit" NAME="Apply" VALUE="Submit">
    </CENTER>
    BUT,,,, it still calls the index.asp page even when the function returns false.

    How do I fix that?

  3. #3

    Thread Starter
    Frenzied Member longwolf's Avatar
    Join Date
    Oct 2002
    Posts
    1,343

    Re: Validate text boxes with vbscript

    I gave up on this and switched to a javascript that MS has up:
    http://support.microsoft.com/kb/216435

    I'm not marking the thread resolved because I still don't have a vbscript solution.

  4. #4
    Hyperactive Member gtilles's Avatar
    Join Date
    Dec 2004
    Location
    Planet Earth
    Posts
    394

    Re: Validate text boxes with vbscript

    And you probably don't want a VB script solution.
    VBScript is not supported in all browsers.
    stay with javascript solution
    Truly, you have a dizzying intellect.

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