1 A
1 A
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<form>
<br>
<br>
<br>
<br>
<br>
</form>
</head>
<body>
<button>Login </button>
<button>reset</button>
</body>
</html>
1B
<!DOCTYPE html>
<html>
<head>
<title>Login Page</title>
<style>
body {
font-family: sans-serif;
.error {
color: red;
font-size: small;
</style>
</head>
<body>
<h2>Login</h2>
<label for="email">Email:</label><br>
</form>
<script>
function validateForm() {
// Username validation
if (!/^[a-zA-Z]{1,25}$/.test(username)) {
isValid = false;
} else {
usernameError.textContent = "";
// Password validation
if (!/^(?=.*[A-Z])(?=.*\d{4})(?=.*[!@#$%^&*()_+\-=\[\]{};':"\\|,.<>\/?]).{8,}$/.test(password)) {
isValid = false;
} else {
passwordError.textContent = "";
isValid = false;
} else {
confirmPasswordError.textContent = "";
if (!/^\d{10}$/.test(mobile)) {
isValid = false;
} else {
mobileError.textContent = "";
// Email validation
if (!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(email)) {
isValid = false;
} else {
emailError.textContent = "";
return isValid;
</script>
</body>
</html>
2a.
<html>
<body>
<p id="disp"></p>
<button type="button" onclick ="getTextFile()">Click here to get the data from text file </button>
<script>
function getTextFile()
xhttp.open("GET","text.txt");
xhttp.onreadystatechange=function()
{
document.getElementById("disp").innerHTML=this.responseText;
};
xhttp.send();
</script>
</body>
</html>
2b
Xml:
<bookstore>
<book>
<title> programming in "C" </title>
<author> yeswanth </author>
<year> 2005 </year>
<price> $2.3 </price>
</book>
<book>
<title> database </title>
<author> raghuawr </author>
<year> 2002 </year>
<price> $2.3222 </price>
</book>
</bookstore>
<html>
<body>
<h1>The XMLHTTPRequest Object of Books Details</h1>
<button type="button" onclick="loadDoc()">Get BooksDetails</button>
<br><br>
<table id="disp"></table>
<script>
function loadDoc()
{
var xhttp = new XMLHttpRequest();
xhttp.open("GET","data.xml");
xhttp.onreadystatechange = function()
{
if(this.readyState === 4 && this.status === 200)
{
myFunction(this);
}
};
xhttp.send();
}
function myFunction(xml)
{
var i;
var xmlDoc = xml.responseXML;
var
table="<tr><th>Title</th><th>Author</th><th>Year</th><th>Price</th><tr>";
var x = xmlDoc.getElementsByTagName("book");
for(i=0;i<x.length;i++)
{
table += "<tr><td>" + x[i].getElementsByTagName("title")
[0].childNodes[0].nodeValue + "</ts><td>" +
x[i].getElementsByTagName("author")
[0].childNodes[0].nodeValue + "</td><td>" +
x[i].getElementsByTagName("year")
[0].childNodes[0].nodeValue + "</td><td>" +
x[i].getElementsByTagName("price")
[0].childNodes[0].nodeValue + "</td><td>";
}
document.getElementById("disp").innerHTML = table;
}
</script>
</html>
</body>