0% found this document useful (0 votes)
5 views

CSS Pract-11 Merged

Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views

CSS Pract-11 Merged

Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 8

Practical No.

11:-Develop a webpage for placing the window on the screen


and working with child window.
Code-1:

<html>

<head>

<title>Open new window</title>

<script>

function openWindow()

myWindow = window.open('pract1.html', 'My Window', 'top=100, left=100, width=250,


height=100,status=1')

</script>

</head>

<body>

<form action="#">

<input type="button" value="Open Window" onclick="openWindow()"/>

</form>

</body>

</html>

Output:
Code-2:

<html>

<body>

<p>Click the button to open a new window and close the window after three seconds (3000

milliseconds)</p>

<button onclick="openWin()">Open "myWindow"</button>

<script>

function openWin() {

var myWindow = window.open("", "myWindow", "width=200, height=100");

myWindow.document.write("<p>This is 'myWindow'</p>");

setTimeout(function(){ myWindow.close() }, 3000);

</script>

</body>

</html>
Output:
Code-3:

<!DOCTYPE html>

<html>

<head>

<script>

function myFunction()

var myWindow = window.open("", "myWin");

myWindow.document.write("<p>Working With Child Window'");

myWindow.document.write("<p>This is 'myWin'");

myWindow.document.write("<br>ScreenX: " + myWindow.screenX);

myWindow.document.write("<br>ScreenY: " + myWindow.screenY + "</p>");

</script>

</head>

<body>

<button onclick="myFunction()">Open "myWin"</button>

</body>

</html>

Output:
Practical No.12:- Develop a web page for validation of form fields using
regular expressions.

Code-1: Write a JavaScript to test if string contains the letter ‘a’ or ‘c’ or both.

<html>

<body>

<script language="javascript">

var input = prompt('Enter some text')

re = /[ac]/

if(re.test(input)) {

alert('The string contains letter a or c or both')

else {

alert('String does not contain a or c or both')

</script>

</body>

</html>

Output:
Code-2: Develop a program to check for valid email id entered by user.

<html>

<head>

<title>Check Email ID</title>

<script>

function checkEmail()

var email = document.getElementById('email').value

var regex = /^([a-zA-Z0-9_\.]+)@([a-zA-Z0-9_\.]+)\.([a-zA-Z]{2,5})$/

var res = regex.test(email)

if(!res) {

alert('Please enter valid email id')

else {

alert('Thank you')

</script>

</head>

<body>

<form name="myform" action="#" method="post">


Enter Email ID <input type="text" id="email" /><br/>

<input type="button" value="Submit" onclick="checkEmail()"/>

</form>

</body>

</html>

Output:

You might also like