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

JavaScript Practical No 1

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views

JavaScript Practical No 1

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

JavaScript Practical No - 1

Code:
<!DOCTYPE html>

<html>

<head>

<title> SOP 1 JAVASCRIPT </title>

<script type = "text/javascript">

function validate_email()

var x = f1.txt_email.value;

var at_pos = x.indexOf("@");

var last_pos = x.lastIndexOf("@");

var firstdot_pos = x.indexOf(".");

var dot_pos = x.lastIndexOf(".");

if(at_pos<1||dot_pos<at_pos+2||dot_pos+2>=x.length||firstdot_pos<at_pos||at_pos
<last_pos)

alert("Not an Valid email address");

f1.txt_email.focus();

else

alert("Valid Email Address");

</script>

</head>

<body>

<H1> INFORMATION TECHNOLOGY </H1>

<FORM Name = "f1">

YOUR NAME :-

<INPUT Type = "text" Name = "txt_name">

<BR><BR>

YOUR ADDRESS :- <TEXTAREA Id = "txt1"

placeholder = "permanent address"

onfocus="this.placeholder = ''"

onblur="this.placeholder = 'permanent address'"/>

</TEXTAREA>
<BR><BR>

CONTACT:-

<INPUT Type = "tel" Name = "telephone" Max="10">

<BR><BR>

EMAIL:-

<INPUT Type = "email" Name = "txt_email" Pattern ="[A-Z a-z]-[@]{1}-[.]{1}">

<BR><BR>

<INPUT Type = "button" Name = "b1" Value = "submit" onclick = "validate_email()">

</form>

</body>

</html>

Output:

You might also like