JSCRIPT:
JScript is Microsoft's implementation of an ECMA-compliant scripting language (like JavaScript) that is targeted specifically to the Internet. Like VBScript, JScript is implemented as a fast, portable interpreter for use in Web browsers and applications that use ActiveX controls, Java applets, and OLE Automation servers. JScript is not Java and has nothing to do with Java. It is closer in syntax to C or C++. If you are a C or C++ developer, you will probably find JScript to be a very easy scripting language to learn (I know I did).
Also like VBScript, JScript supports three separate classes of objects for use within JScript:
![]() |
Objects provided by the JScript engine |
![]() |
Objects provided by Internet Explorer (found in the Microsoft Scripting site |
![]() |
Objects provided by the Web page author via the HTML <OBJECT> tag. |
The Hello World
example is the bare-bones JScript example. It provides a button that, when clicked,
displays a message box with the text, "Hello, world!"
<CENTER> <P> <H2>Hello, world sample</H2> <FORM Name="Form1" ACTION=""> <INPUT TYPE=BUTTON VALUE="Click me" NAME="BtnHello" OnClick="sayhello()" > </FORM> </CENTER> <SCRIPT LANGUAGE="JavaScript"> <!-- function sayhello () { alert("Hello, world!") } //--> </SCRIPT>
Here again, HTML code is used to set up the button and JScript is used to perform an action (displaying the message box using the alert function) when the button is clicked.
The second Ordering Flowers
example demonstrates client-side validation using JScript. As in the VBScript example,
this example uses radio buttons to enable the user to choose which type of card to include
with the flowers, text input fields to gather information on where to send the flowers,
and a button to submit the request. The HTML source code is the same for this example as
it is for the VBScript example, so I won't show it here. What is different, however, is
the script. The following JScript code is used to do client-side validation:
<SCRIPT LANGUAGE="JavaScript"> <!-- var bValidOrder var f = document.form1 function Init() { var d document.form1.TxtName.value = "Joe Smith" document.form1.TxtAddress.value = "1 Main Street" document.form1.TxtCity.value = "Springfield" document.form1.TxtState.value = "Washington" document.form1.TxtZip.value = "12345" d = new Date() d.setDate(d.getDate() + 3) f.TxtDate.value = (d.getMonth() + 1) + "/" + d.getDate() + "/" + d.getYear() } function SubmitOrder() { bValidOrder = true CheckSpecified(f.TxtName.value,"Please specify a name.") CheckSpecified(f.TxtAddress.value,"Please specify an address.") CheckSpecified(f.TxtCity.value,"Please specify a city.") CheckSpecified(f.TxtState.value,"Please specify a state.") CheckSpecified(f.TxtZip.value,"Please specify a zip code.") CheckSpecified(f.TxtDate.value,"Please specify a date.") ValidateDeliveryDate() if (bValidOrder) { alert("Thank you for your order!") // TODO: Actually send the order. } } function ValidateDeliveryDate() { var SoonestWeCanDeliver var RequestedDate var t if (bValidOrder) { SoonestWeCanDeliver = new Date() SoonestWeCanDeliver.setDate(SoonestWeCanDeliver.getDate() + 2) t = Date.parse(f.TxtDate.value) RequestedDate = new Date() RequestedDate.setTime(t) if (RequestedDate.getTime() < SoonestWeCanDeliver.getTime()) { bValidOrder = false alert("Not even we can deliver that fast!") } } } function CheckSpecified(strFieldValue, strMsg) { if (strFieldValue == "") { if (bValidOrder) { alert(strMsg) bValidOrder = false } } } function Clear() { f.TxtName.value = "" f.TxtAddress.value = "" f.TxtCity.value = "" f.TxtState.value = "" f.TxtZip.value = "" f.TxtDate.value = "" } //--> </SCRIPT>
Links For further details please check