
See Our team
Wondering how we keep quality?
Got unsolved questions? Ask Questions
GATE
GMAT
CBSE
NCERT
Career
Interview
Railway
UPSC
NID
NIFT-UG
NIFT-PG
PHP
AJAX
JavaScript
Node Js
Shell Script
Research
How to design a simple form of javascript and passing that value to a function?
(This program also can be found in vtu webprogramming lab manual)
a) Develop and demonstrate, using Javascript script, a XHTML document that collects the USN ( the valid format is: A digit from 1 to 4 followed by two upper-case characters followed by two digits followed by two upper-case characters followed by three digits; no embedded spaces allowed) of the user. Event handler must be included for the form element that collects this information to validate the input. Messages in the alert windows must be produced when errors are detected.
b) Modify the above program to get the current semester also (restricted to be
a number from 1 to 8)
<!DOCTYPE html PUBLIC "_//w3c//DTD//XHTML 1.1//EN""http://www.w3.org/TR/xhtml11/DTD/xhtml.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<script type="text/javascript">
function formValidator()
{
var usn=document.getElementById('req1');
if(isCorrect(usn))
{
return true;
}
return false;
}
function isCorrect(elem1)
{
var alphaexp1 = /[1-4][A-Za-z][A-Za-z][0-9][0-9][A-Za-z][A-Za-z][0-9][0-9][0-9]$/;
if(elem1.value.length==0)
{
alert("please enter the input");
elem1.focus();
return false;
}
else if(!elem1.value.match(alphaexp1))
{
alert("enter the input in DAADAADDD format");
elem1.focus();
return false;
}
else
{
alert("USN is correct");
return true;
}
}
</script>
</head>
<body>
<form onsubmit="return formValidator( )">
enter the usn<input type="text"id='req1'/>
<input type="submit"value="check field"/>
</form>
</body>
</html>
We made eduladder by keeping the ideology of building a supermarket of all the educational material available under one roof. We are doing it with the help of individual contributors like you, interns and employees. So the resources you are looking for can be easily available and accessible also with the freedom of remix reuse and reshare our content under the terms of creative commons license with attribution required close.
You can also contribute to our vision of "Helping student to pass any exams" with these. Answer a question: You can answer the questions not yet answered in eduladder.How to answer a question Career: Work or do your internship with us.Work with us Create a video: You can teach anything and everything each video should be less than five minutes should cover the idea less than five min.How to upload a video on eduladder