Website Design Nepal
Web Design Nepal, Website Design Nepal are the basic abstraction of this page.

Form Validation in JavaScript

Form Validation using FORM

<html>

<head>

<title>JavaScript Form Validation</title>

<script language=”javascript” type=”text/javascript”>

function frmValidation()

{

if(document.form1.fname.value==”") // checking whether the field fname in form1 has blank value in it or not

{

alert(“First Name cannot be left blank.”);

document.form1.fname.focus(); // this takes the cursor and puts it inside the fname field

return false; // return false prohibits the form submission

}

else if(document.form1.lname.value==”")

{

alert(“Last Name cannot be left blank.”);

document.form1.lname.focus();

return false;

}

else if(document.form1.email.value==”")

{

alert(“Email cannot be left blank.”);

document.form1.email.focus();

return false;

}

else if(document.form1.uname.value==”")

{

alert(“User Name cannot be left blank.”);

document.form1.uname.focus();

return false;

}

else if(document.form1.pword.value==”")

{

alert(“Password cannot be left blank.”);

document.form1.pword.focus();

return false;

}

//defining an expression or format that an email must have

var exp=/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/;

if (!exp.test(document.form1.email.value))

{

alert(“Please enter valid Email Address.”);

document.form1.email.focus();

return false;

}

}

</script>

</head>

<body>

<form name=”form1″ method=”post” action=”">

First Name <input name=”fname” type=”text” id=”fname”>  <br>

Last Name <input name=”lname” type=”text” id=”lname”><br>

Email <input name=”email” type=”text” id=”email”><br>

User Name <input name=”uname” type=”text” id=”uname”><br>

Password <input name=”pword” type=”password” id=”pword”> <br><br>

<input type=”submit” name=”Submit” value=”Submit” onClick=”return frmValidation()”>

</form>

</body>

</html>

Form validation  by Elements

<html>

<head>

<title>JavaScript Form Validation 2</title>

<script language=”javascript” type=”text/javascript”>

function frmValidation()

{

var i;

for(i=1;i<=5;i++)

{

if(document.getElementById(i).value==”") // checking whether the field with id=1,2,3,4,5 in this page has blank value in it or not

{

alert(“Please fill in the focussed field.”);

document.getElementById(i).focus(); // this takes the cursor and puts it inside the blank focussed field

return false; // return false prohibits the form submission

}

}

//defining an expression or format that an email must have

var exp=/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/;

if (!exp.test(document.getElementById(3).value))

{

alert(“Please enter valid Email Address.”);

document.getElementById(3).focus();

return false;

}

}

</script>

</head>

<body>

<form name=”form1″ method=”post” action=”">

First Name   <input name=”fname” type=”text” id=”1″>   <br>

Last Name <input name=”lname” type=”text” id=”2″><br>

Email <input name=”email” type=”text” id=”3″><br>

User Name <input name=”uname” type=”text” id=”4″> <br>

Password <input name=”pword” type=”password” id=”5″> <br> <br>

<input type=”submit” name=”Submit” value=”Submit” onClick=”return frmValidation()”>

</form>

</body>

</html>

WordPressStumbleUponShare

Issues of Web Technology

HTTP: Hyper Text Transfer Protocol

HTTP is a request/response standard between a client and a server. A client is the end-user, the server is the web site. The client making a HTTP request-using a web browser, spider, or other end-user tool-is referred to as the user agent. The responding server-which stores or creates resources such as HTML files and images-is called the origin server. In between the user agent and origin server may be several intermediaries, such as proxies, gateways, and tunnels. HTTP is not constrained to using TCP/IP and its supporting layers, although this is its most popular application on the Internet. Indeed HTTP can be “implemented on top of any other protocol on the Internet, or on other networks. HTTP only presumes a reliable transport; any protocol that provides such guarantees can be used.”

HTTP Request methods

HTTP defines eight methods indicating the desired action to be performed on the identified resource. What this resource represents, whether pre-existing data or data that is generated dynamically, depends on the implementation of the server. Often, the resource corresponds to a file or the output of an executable residing on the server.

HEAD
Asks for the response identical to the one that would correspond to a GET request, but without the response body. This is useful for retrieving meta-information written in response headers, without having to transport the entire content.

GET
Requests a representation of the specified resource. Note that GET should not be used for operations that cause side-effects, such as using it for taking actions in web applications. One reason for this is that GET may be used arbitrarily by robots or crawlers, which should not need to consider the side effects that a request should cause. See safe methods below.

POST
Submits data to be processed (e.g., from an HTML form) to the identified resource. The data is included in the body of the request. This may result in the creation of a new resource or the updates of existing resources or both.

PUT
Uploads a representation of the specified resource.

DELETE
Deletes the specified resource.

TRACE
Echoes back the received request, so that a client can see what intermediate servers are adding or changing in the request.

OPTIONS
Returns the HTTP methods that the server supports for specified URL. This can be used to check the functionality of a web server by requesting ‘*’ instead of a specific resource.

CONNECT
Converts the request connection to a transparent TCP/IP tunnel, usually to facilitate SSL-encrypted communication (HTTPS) through an unencrypted HTTP proxy.

HTTP servers are required to implement at least the GET and HEAD methods and, whenever possible, also the OPTIONS method.

FTP: File Transfer Protocol

File Transfer Protocol (FTP) is a network protocol used to transfer data from one computer to another through a network such as the Internet.

FTP is a file transfer protocol for exchanging and manipulating files over a TCP computer network. An FTP client may connect to an FTP server to manipulate files on that server.

Tier Technology

Two Tier Architechture

Two Tier Architechture

WordPressStumbleUponShare
© 2003-2012 Copyright , Young Minds, Kathmandu, Nepal. All rights reserved.