pass variables to a WSH script

A how-to code example from ASPFree.

Contributed by
Rating: 1 stars1 stars1 stars1 stars1 stars / 1
February 05, 2002
Rate this Article:
MEH MEH++


SEARCH ASP FREE
TOOLS YOU CAN USE

advertisement

<html>
<
head>
<
title>Form Validation Using JavaScript</title>
<
script LANGUAGE="JavaScript">
<!--
Hides Code
function validateIt() //function is called when the button is clicked
{
    var
dblNum;
    var
txtText;
    var
txtMessage;
    
dblNum = 0.1;
    if(!
isNaN(document.form1.txtNum.value))  /* document.[form name].[field name].value   Checks to see if it is a number (isNaN: Not a Number) */
        
{
        
dblNum = document.form1.txtNum.value;  /* alerts display message boxes */
        
}
    else
        {
        
alert("Field must contain a number");
        
document.form1.txtNum.focus();
        return;
        }
    
txtText = document.form1.txtText.value;
    if(!
isNaN(document.form1.txtText.value))
        {
        
alert("Requires text, and not a number");
        
document.form1.txtText.focus();
        return;
        }
    if(
txtText.length < 8) /* checks to see if the lenght of the text field is greater than 8 */
        
{
        
alert("Text must be at least 8 letters long");
        
document.form1.txtText.focus();
        return;
        }
    if(
dblNum < 250.55) /* makes sure that the number entered meets the criteria */
        
{
        
alert("Number must be greater than 250.55")
        
document.form1.txtNum.focus();
        return;
        }
    
alert("Everything Checks Out Fine")
    return;
}
//-->
</script>
</head>
<body background="../images/aspfreebkgrnd.gif">
<p>How to validate a form entry using javascript:</p>
<form method="POST" name="form1" action="javaform.asp" webbot-action="--WEBBOT-SELF--">
<div align="center">
<center>
<table border="0" cellpadding="0" cellspacing="0" width="44%">
<tr>
<td width="41%">Text of 8 letters: </td>
<td width="59%"><input type="text" name="txtText" size="20"></td>
</tr>
<tr>
<td width="41%">Number > 250.55</td>
<td width="59%"><input type="text" name="txtNum" size="20"></td>
</tr>
<tr>
<td width="41%" colspan="2">
<p align="center"><input type="button" value="Button" name="B1" onClick="validateIt();"></td></tr>
</table>
</center>
</div>
</form>
</body>
</html>

blog comments powered by Disqus
WINDOWS SCRIPTING ARTICLES

- More Windows Scripting Workarounds from Nilpo
- Overloading Methods and More in VBScript
- Improving MFC for Windows Vista
- Regular Expressions in VBScript
- Working with Dates in WMI
- Completing Calendars with VBScript Date Func...
- Building Calendars with VBScript Date Functi...
- Working With Dates and Times in VBScript
- Designing WCF DataContract Classes Using the...
- Understanding Dates and Times in VBScript
- Working With Arrays in VBScript
- Compressed Folders in WSH
- Using .NET Interops in VBScript
- Nilpo`s Scripting Secrets, Vol I
- Database operations using Silverlight 2.0 WC...

ASP Web Hosting ASP.Net Web Hosting Windows Web Hosting
 
 
 

ASP Free Forums 
 RSS  Tutorials RSS
 RSS  Forums RSS
 RSS  All Feeds
Site Map 
Request Media Kit
Write For Us Get Paid 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
Privacy Policy 
Support 


© 2003-2012 by Developer Shed. All rights reserved. DS Cluster 8 - Follow our Sitemap
Most Popular Topics
All ASP.Net Tutorials