VBScript and Forms (10)

Source: Internet
Author: User
VBScript and Forms
Simple validation
With Visual Basic scripting Edition, you can accomplish a large amount of form processing that you typically do on a server, or you can do work that you cannot do on the server.
This is a simple example of client-side validation. The result of the HTML code is a text box and a button. If you use Microsoft®internet Explorer to view a page made with the following code, you will see a small text box with a button next to it.
<HTML>
<HEAD><TITLE> Simple Validation </TITLE>
<script language= "VBScript" >
<!--
Sub Validate
Dim theform
Set theform = document.forms ("ValidForm")
If IsNumeric (TheForm.Text1.Value) Then
If TheForm.Text1.Value < 1 Or TheForm.Text1.Value > Then
MsgBox "Please enter a number from 1 to 10." "
Else
MsgBox "Thank you." "
End If
Else
MsgBox "Please enter a number. "
End If
End Sub
-->
</SCRIPT>
</HEAD>
<BODY>
<H3> Simple Validation </H3><HR>
<form id= "ValidForm" action= "nothing.asp" onsubmit= (); return false; language= "JScript" >
Please enter a number from 1 to 10:
<input name= "Text1" type= "TEXT" class= ' 9v ' >
<input name= "Submit" type= "Submission" value= "submitted" >
</form>
</BODY>
</HTML>
The difference between this text box and the sample in the simple example of a VBScript page is that the Value property of the text box is used to check the input value. To use the Value property of a text box, the code must refer to the name of the text box.
Each time you reference a text box, you should write the full name, that is, Document.ValidForm.Text1. However, when you refer to a form control multiple times, you can follow these steps: First declare a variable, and then assign the form Document.validform to the variable theform using the Set statement, so that you can use THEFORM.TEXT1 to reference the text box. A regular assignment statement, such as Dim, is not valid here, and you must use Set to keep a reference to an object.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.