{
var x=document.forms["myForm"]["fname"].value;
if (x==null || x=="")
{
alert("First name must be filled out");
return false;
}
}
The function above could be called when a form is submitted:
Example
<form name="myForm" action="demo_form.asp" onsubmit="return validateForm()"
method="post">
First name: <input type="text" name="fname">
<input type="submit" value="Submit">
</form>
E-mail Validation
The function below checks if the content has the general syntax of an email.
This means that the input data must contain an @ sign and at least one dot (.). Also, the
@ must not be the first character of the email address, and the last dot must be
present after the @ sign, and minimum 2 characters before the end:
function validateForm()
{
var x=document.forms["myForm"]["email"].value;
var atpos=x.indexOf("@");
var dotpos=x.lastIndexOf(".");
if (atpos<1 || dotpos<atpos+2 || dotpos+2>=x.length)
{
alert("Not a valid e-mail address");
return false;
The function above could be called when a form is submitted:
Example
<form name="myForm" action="demo_form.asp" onsubmit="return validateForm();"
method="post">
Email: <input type="text" name="email">
<input type="submit" value="Submit">
</form>
Practice Exercise:
S.No. Query statement
1 To Design an XML document to store information about a student in an engineering college affiliated to CSVTU. The information must include RollNo, Name, Name of the College, Branch, Year of Joining, and e-mail id. Make up sample data for 5 students. Create a CSS style sheet and use it to display the document.
ACCEPTANCE CRITERIA
For the acceptance of your program keep in mind following set of points that you have to cover while developing a program and record book:-
Acceptance Points Remarks
Web page design
Web page must be designed in proper way by keeping in mind all the correct syntax of mark up language
Correct implementation HTML,CSS, XHTML code must implemented
correctly
Report Book
It consists of following sections:
Problem Statement Lab Exercise 5.
Observation after each practice exercise
POST LAB ASSIGNMENT
Create a XHTML web page for your personal profile which consists of your personal detail and academic detail validate that web page using java script.
REFERENCES
Bibliography:
HTML and XML complete reference.
Websites:
www.w3schools.com
FAQ’S
What is Java Script and why we need this?
Demonstrate java script document writing?
Demonstrate java script looping?
Demonstrate java script if…..else?
Demonstrate java script pop up box?
What is XML ?
Difference between XML and HTML?
LAB -10
PROBLEM STATEMENT
On completion of Lab 10 student shall be able to:
Design basic html and CSS document.
Develop XHTML web page containing XML java script with event handler.
Develop XSLT sheet.
THEORY
XSLT Introduction
XSLT is a language for transforming XML documents into XHTML documents or to other XML documents.
XPath is a language for navigating in XML documents.
What You Should Already Know
Before you continue you should have a basic understanding of the following:
HTML / XHTML
XML / XML Namespaces
XPath
What is XSLT? XSLT stands for XSL Transformations
XSLT is the most important part of XSL
XSLT transforms an XML document into another XML document
XSLT uses XPath to navigate in XML documents
XSLT is a W3C Recommendation
To Create an XSLT style sheet for one student element of the above document and use it to create a display of that element.
XSLT = XSL Transformations
XSLT is the most important part of XSL.
XSLT is used to transform an XML document into another XML document, or another type of document that is recognized by a browser, like HTML and XHTML. Normally XSLT does this by transforming each XML element into an (X)HTML element.
With XSLT you can add/remove elements and attributes to or from the output file. You can also rearrange and sort elements, perform tests and make decisions about which elements to hide and display, and a lot more.
A common way to describe the transformation process is to say that XSLT transforms an XML source- tree into an XML result-tree.
XSLT Uses XPath
XSLT uses XPath to find information in an XML document. XPath is used to navigate through elements and attributes in XML documents.
If you want to study XPath first, please read our XPath Tutorial.
How Does it Work?
In the transformation process, XSLT uses XPath to define parts of the source document that should match one or more predefined templates. When a match is found, XSLT will transform the matching part of the source document into the result document.
XSLT is a W3C Recommendation
XSLT became a W3C Recommendation 16. November 1999.
Introduction to XML
XML was designed to transport and store data. HTML was designed to display data.
What You Should Already Know
Before you continue you should have a basic understanding of the following:
HTML
JavaScript
What is XML? XML stands for EXtensible Markup Language
XML is a markup language much like HTML
XML was designed to carry data, not to display data
XML tags are not predefined. You must define your own tags
XML is designed to be self-descriptive
XML is a W3C Recommendation
The Difference Between XML and HTML
XML is not a replacement for HTML.
XML and HTML were designed with different goals:
XML was designed to transport and store data, with focus on what data is
HTML was designed to display data, with focus on how data looks HTML is about displaying information, while XML is about carrying information.
XML Does Not DO Anything
Maybe it is a little hard to understand, but XML does not DO anything. XML was created to structure, store, and transport information.
The following example is a note to Tove, from Jani, stored as XML: <note>
<to>Tove</to> <from>Jani</from>
<heading>Reminder</heading>
<body>Don't forget me this weekend!</body> </note>
The note above is quite self descriptive. It has sender and receiver information, it also has a heading and a message body.
But still, this XML document does not DO anything. It is just information wrapped in tags. Someone must write a piece of software to send, receive or display it.
With XML You Invent Your Own Tags
The tags in the example above (like <to> and <from>) are not defined in any XML standard. These tags are "invented" by the author of the XML document.
That is because the XML language has no predefined tags.
The tags used in HTML are predefined. HTML documents can only use tags defined in the HTML standard (like <p>, <h1>, etc.).
XML allows the author to define his/her own tags and his/her own document structure.
XML is Not a Replacement for HTML XML is a complement to HTML.
It is important to understand that XML is not a replacement for HTML. In most web applications, XML is used to transport data, while HTML is used to format and display the data.
My best description of XML is this:
XML is a software- and hardware-independent tool for carrying information.
XML is a W3C Recommendation
XML became a W3C Recommendation on February 10, 1998.
To read more about the XML activities at W3C, please read our W3C Tutorial.
XML is Everywhere
Practice Exercise:
S.No. Query statement
1 To Create an XSLT style sheet for one student element of the above document and use it to create a display of that element.
ACCEPTANCE CRITERIA
For the acceptance of your program keep in mind following set of points that you have to cover while developing a program and record book:-
Acceptance Points Remarks
Web page design
Web page must be designed in proper way by keeping in mind all the correct syntax of mark up language
Correct implementation HTML,CSS, XHTML code must implemented
correctly
Report Book
It consists of following sections:
Problem Statement Lab Exercise 5.
Observation after each practice exercise
POST LAB ASSIGNMENT
Create a XHTML web page for your personal profile which consists of your personal detail and academic detail validate that web page using java script.
Create XSLT sheet to display and store employee information.
REFERENCES
Bibliography:
HTML and XML complete reference.
Websites:
FAQ’S
What is Java Script and why we need this?
Demonstrate java script document writing?
Demonstrate java script looping?
Demonstrate java script if…..else?
Demonstrate java script pop up box?
What is XML ?
Difference between XML and HTML?
Why we need to create XML web page?
What is XSLT?