Posted by: Sourav | July 3, 2013

Form in Javascript


<html>
<head>
<title>

Javascript Example
</title>
<script type=”text/javascript”>

function pop(){
var name=document.forms[0].nametext.value;
if(name==”steve”)
{
alert(“Hello Steve,Welcome to the machine”);

}
else if(name==”nancy”)
{
alert(“Hello Nancy”);

}
else
{
alert(“Hello”+name);
}
return 0;
}

</script>

</head>
<body>

<form id=”myform” action=”#” onsubmit=”return pop()”>

<p>Username:&nbsp;&nbsp;&nbsp;<input id=”nametext” name=”username” type=”text” </p>
<p><input type=”submit” /> </p>

</form>

</body>

</html>

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Categories

%d bloggers like this: