0% found this document useful (0 votes)
3 views5 pages

Java Script SOP

The document contains multiple JavaScript examples demonstrating various functionalities, including an information form with email validation, a vowel counter, a palindrome checker, and a program to calculate average marks and assign grades. Each example is structured in HTML with embedded JavaScript functions to handle user input and display results. The examples illustrate basic form handling and validation techniques in JavaScript.

Uploaded by

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

Java Script SOP

The document contains multiple JavaScript examples demonstrating various functionalities, including an information form with email validation, a vowel counter, a palindrome checker, and a program to calculate average marks and assign grades. Each example is structured in HTML with embedded JavaScript functions to handle user input and display results. The examples illustrate basic form handling and validation techniques in JavaScript.

Uploaded by

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

Java Script SOP 2

<!DOCTYPE html>

<html>

<head> <title>Sop 2 JAVaScript</title></head>

<body>

<h1>Information Form</h1>

<form name="f1">

Your Name: <input type="text" name="txt_name"><br><br>

Address: <textarea name="txt_address" placeholder="Permanent Address"/></textarea><br><br>

Contact: <input type="tel" name="telephone" maxlength="10"><br><br>

Email: <input type="email" name="txt_email" pattern="[A-Z a-z]{0-9}-[@]{1}-[.]{1}"><br><br>

<input type="button" name="b1" value="submit" onclick="validate_email()">

</form>

</body>

<script type="text/javascript">

function validate_email()

var x=f1.txt_email.value;

var at_pos=[Link]("@");

var last_pos=[Link]("@");

var firstdot_pos=[Link](".");

var dot_pos=[Link](".");

if(at_pos<1||dot_pos<at_pos+2||dot_pos+2>=[Link]||firstdot_pos<at_pos||at_pos<last_pos)

{ alert("Not an Valid email address");

f1.txt_email.focus();

else { alert("Valid Email Address");

return true;

</script></html>
SOP 3

<!DOCTYPE html>

<html>

<head>

<title>Sop 3 JAVasript Count vowels</title>

</head>

<body>

<form name="form1">

<h1>Enter the String whose vowel isto be counted</h1>

<input type="text" name="text1">

<input type="button" name="btn_checkvowel" value="Click to count" onclick="count()">

</form>

<script type="text/javascript">

function count()

var i,ch,str,counter=0;

str=[Link];

for(i=0;i<[Link];i++)

ch=[Link](i);

if(ch=='A'||ch=='a'||ch=='e'||ch=='E'||ch=='i'||ch=='I'||ch=='o'||ch=='O'||ch=='u'||ch=='U')

counter++;

alert("Number of Vowels in Entered String is:"+counter);

</script>

</body>

</html>
JavaScript SOP 4
<!DOCTYPE html>

<html>

<head> <title>JavaScript SOP 4 Example</title></head>

<body>

<form name="f1">

Enter the string to check it is palindrome or not! <br>

<input type="text" name="t1"> <br><br>

<input type="button" name="check_palin" value="Check String"


onclick="chk_palindrome()">

</form>

<script type="text/javascript">

function chk_palindrome()

var str,str_case,i,len;

str=[Link];

str_case=[Link]();

len=str_case.length;

var p=1;

for(i=0;i<len/2;i++)

if(str_case.charAt(i)!=str_case.charAt(len-1-i))

p=0;

break;

if(p==1)

alert("Entered string is Palindrome");

}
else

alert("Entered string is Not a Palindrome")

</script>

</body>

</html>

JavaScript SOP 6
<!DOCTYPE html>

<html>

<head> <title>Sop 6 Javascript program</title></head>

<body>

<h1> Javascript program to compute average marks of students</h1>

<form name="form1">

<p>Enter Marks of subjects of students <br><br>

English Marks: <input type="text" name="txt_eng"> <br><br>

Physics Marks: <input type="text" name="txt_phy"> <br><br>

Chemistry Marks: <input type="text" name="txt_chem"><br><br>

IT Marks: <input type="text" name="txt_it"> <br><br>

Maths Marks: <input type="text" name="txt_maths"> <br><br>

Biology Marks: <input type="text" name="txt_bio"> <br><br>

<input type="submit" value="Calculate Average & print grade" onclick="calculate_grade()">

</form>

<script type="text/javascript">

function calculate_grade()

var m1,m2,m3,m4,m5,m6,avg;

m1=parseInt(form1.txt_eng.value);

m2=parseInt(form1.txt_phy.value);
m3=parseInt(form1.txt_chem.value);

m4=parseInt(form1.txt_it.value);

m5=parseInt(form1.txt_maths.value);

m6=parseInt(form1.txt_bio.value);

avg=(m1+m2+m3+m4+m5+m6)/6; //computes the average of six subjects of students

alert("Average marks of students for six subjects is:"+ avg);

if(avg>=91 && avg<=100)

grade = 'A';

else if(avg>=81 && avg<=90)

grade = 'B';

else if(avg>=71 && avg<=80)

grade = 'C';

else if(avg>=61 && avg<=70)

grade = 'D';

else if (avg>=35 && avg<=60)

grade = 'F';

alert ("Grade of the student is: "+ grade);

</script>

</body>

</html>

You might also like