/    /  Javascript Forms

Javascript Forms

 

Forms are the basics of HTML. You can use HTML form element in order to create the JavaScript form. For creating a form, you can use the following example code.

 

EXAMPLE:

 

<html> 
<head> 
<title> Login Form</title> 
</head> 
<body> 
<h3> LOGIN </h3> 
<formform ="Login_form" onsubmit="submit_form()"> 
<h4> USERNAME</h4> 
<input type="text" placeholder="Enter your email id"/> 
<h4> PASSWORD</h4> 
<input type="password" placeholder="Enter your password"/></br></br> 
<input type="submit" value="Login"/> 
<input type="button" value="SignUp" onClick="create()"/> 
</form> 
</html>

 

⦁ Form name tag is provide to define the name of the form. The name of the form here is “Login_form”. This name(Login_form) will be referenced in the JavaScript form.
⦁ The action tag provides the action, and the browser will take to tackle the form when it is submitted. Here, we have taken no action.
⦁ The method to take action can be either post or get, which is provided when the form is to be submitted to the server.
⦁ This two types of methods have their own properties and rules.

 

Login Form:

 

<html> 
<head> 
<title> Login Form</title> 
</head> 
<body> 
<h3> LOGIN </h3> 
<formform ="Login_form" onsubmit="submit_form()"> 
<h4> USERNAME</h4> 
<input type="text" placeholder="Enter your email id"/> 
<h4> PASSWORD</h4> 
<input type="password" placeholder="Enter your password"/></br></br> 
<input type="submit" value="Login"/> 
<input type="button" value="SignUp" onClick="create()"/> 
</form> 
<script type="text/javascript"> 
function submit_form(){ 
alert("Login successfully"); 
} 
function create(){ 
window.location="signup.html"; 
} 
</script> 
</body> 
</html>

 

Javascript Forms