Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


Prashant
Struts
4 Answer(s)      5 years and 11 months ago
Posted in : Struts



Advertisement
View Answers

October 24, 2008 at 1:25 PM


Hi friend,

This code will help you.


<%@ taglib uri="/tags/struts-bean" prefix="bean" %>
<%@ taglib uri="/tags/struts-html" prefix="html" %>
<html:html locale="true">

<head>
<title>User Registration</title>
<html:base/>
<SCRIPT LANGUAGE=javascript>

function checkEmail(email) {
if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(email)){
return (true)
}
alert("Invalid E-mail Address! Please re-enter.")
return (false);
}


function validateForm(formObj){

if(formObj.userid.value.length==0){
alert("Please enter User ID!");
formObj.userid.focus();
return false;
}

if(formObj.password.value.length==0){
alert("Please enter password!");
formObj.password.focus();
return false;
}

if(formObj.email.value.length==0){
alert("Please enter Email!");
formObj.email.focus();
return false;
}

if(!checkEmail(formObj.email.value)){
formObj.email.focus();
return false;
}

if(formObj.address.value.length==0){
alert("Please enter address!");
formObj.address.focus();
return false;
}

if(formObj.phno.value.length==0){
alert("Please enter Phone No.!");
formObj.phno.focus();
return false;
}

if(isNaN(formObj.phno.value)){
alert("Please enter correct Phone No!");
formObj.phno.focus();
return false;
}


formObj.actionUpdateData.value="update";
<a href="Sucess.jsp"></a>

}
//-->
</SCRIPT>
</head>
<body>



<center>
<!--
<table width="60%">
<tr>
<td width="100%">
-->
<html:form action="/userRegister" method="post" onsubmit="return validateForm(this);">
<html:hidden property="id"/>
<html:hidden property="action"/>
<html:hidden property="actionUpdateData"/>



<table width="50%" border="1" class="signup" align="center">

<tr>
<td colspan="2" align="center">
<font size="4" color="#660099">Please Enter the Following Details</font><br>
</td>
</tr>

<!--
<tr>
<td align="right" width="50%"><b>Id</b></td>
<td width="50%" align="left">
<html:text property="id" size="30" maxlength="120"/>
</td>
</tr>
-->
<tr><td colspan="2" align="center"><font color="red"><html:errors/></font>

&nbsp;</td></tr>
<tr>
<td align="right" width="50%"><b>User Id<font color="#FF0000">*</font></b></td>
<td align="left" width="50%">
<html:text property="userid" size="30" maxlength="120"/>
</td>
</tr>
<tr>
<td align="right"><b>Password<font color="#FF0000">*</font></b></td>
<td align="left">
<html:password property="password" size="30" maxlength="120"/>
</td>
</tr>

<tr>
<td align="right"><b>Email</b></td>
<td align="left">
<html:text property="email" size="30" maxlength="120"/>
</td>
</tr>


October 24, 2008 at 1:26 PM


<tr>
<td align="right"><b>Address</b></td>
<td align="left">
<html:text property="address" size="30" maxlength="120"/>
</td>
</tr>
<tr>
<td align="right"><b>Phone No.<b></td>
<td align="left">
<html:text property="phno" size="30" maxlength="120"/>
</td>
</tr>

<tr><td>
<html:select name="UserRegisterForm" property="course" size="5">

<html:option value="MBA">select MBA</html:option>
<html:option value="MCA">select MCA</html:option>
<html:option value="BE">select BE</html:option>
<html:option value="B.COM">select B.COM</html:option>

</html:select><br/><br/>
</td></tr>



<tr><td colspan="2">&nbsp;</td></tr>
<tr>
<td align="center" colspan="2">
<html:submit>Save</html:submit>

</td>
</tr>
</table>
</html:form>
<!--
</td>
</tr>
</table>
</center>
-->
</body>
</html:html>


October 24, 2008 at 1:27 PM


package strutsTutorial;
import javax.servlet.http.HttpServletRequest;

import org.apache.struts.action.*;

public class UserRegisterForm extends ActionForm{
private String action="add";
private String actionUpdateData;

private Integer id;

private String userid;
private String password;

private String email;
private String address;
private String phno;

private String course;

public void reset(ActionMapping mapping,HttpServletRequest request){

this.id = null;
this.userid=null;
this.password=null;
this.email=null;
this.address=null;
this.phno=null;

this.action="add";
this.actionUpdateData="";

}


public ActionErrors validate(

ActionMapping mapping, HttpServletRequest request ) {
ActionErrors errors = new ActionErrors();

return errors;
}


public String getAction() {
return action;
}


public void setAction(String action) {
this.action = action;
}


public String getAddress() {
return address;
}


public void setAddress(String address) {
this.address = address;
}


public String getEmail() {
return email;
}


public void setEmail(String email) {
this.email = email;
}


public String getPassword() {
return password;
}


public void setPassword(String password) {
this.password = password;
}


public String getPhno() {
return phno;
}



public void setPhno(String phno) {
this.phno = phno;
}


public String getUserid() {
return userid;
}


public void setUserid(String userid) {
this.userid = userid;
}

public String getActionUpdateData() {
return actionUpdateData;
}

public void setActionUpdateData(String actionUpdateData) {
this.actionUpdateData = actionUpdateData;
}


public String getCourse() {
return course;
}

public void setCourse(String course) {
this.course = course;
}


public Integer getId() {
return id;
}

public void setId(Integer id) {
this.id = id;
}

public UserRegisterForm() {
super();
}


}


October 24, 2008 at 1:28 PM


<%@ taglib uri="/tags/struts-bean" prefix="bean" %>
<%@ taglib uri="/tags/struts-html" prefix="html" %>
<html:html locale="true">

<head>

<title></title>
<html:base/>
</head>
<body>
<center>

<p><b>You are registered successfuly !</b></p>
</center>
<bean:write name="UserRegisterForm" property="course"/>
</body>
</html:html>


Related Tutorials/Questions & Answers:
STRUTS
STRUTS  MAIN DIFFERENCES BETWEEN STRUTS 1 AND STRUTS 2
STRUTS
STRUTS  MAIN DIFFERENCES BETWEEN STRUTS 1 AND STRUTS 2
Advertisements
Struts
Struts   How to retrive data from database by using Struts
Struts
Struts  how to learn struts
Struts
Struts  what is SwitchAction in struts
STRUTS
STRUTS   Request context in struts? SendRedirect () and forward how to configure in struts-config.xml
struts
struts  in industry, struts 1 and struts 2. which is the best? which is useful as a professuional   Have a look at the following link: Struts Tutorials
struts
struts shopping cart project in struts with oracle database connection  shopping cart project in struts with oracle database connection   Have a look at the following link: Struts Shopping Cart using MySQL
struts
struts  what are the 4 methods of struts framework
Struts
Struts  Tell me good struts manual
Struts
Struts   When Submit a Form and while submit is working ,press the Refresh , what will happen in Struts
struts
struts  Hi what is struts flow of 1.2 version struts? i have struts applicatin then from jsp page how struts application flows Thanks Kalins Naik   Please visit the following link: Struts Tutorial
struts
struts  i have no any idea about struts.please tell me briefly about struts?**   Hi Friend, You can learn struts from the given link: Struts Tutorials Thanks
struts
struts  why doc type is not manditory in struts configuration file
struts
struts  why doc type is not manditory in struts configuration file
struts
struts  why doc type is not manditory in struts configuration file
struts
struts   how to write Dao to select data from the database
struts
struts  why doc type is not manditory in struts configuration file
Struts
Struts   in struts I want two struts.xml files. Where u can specify that xml files location and which tag u specified
Struts
Setter methods of form bean class in Struts applications  who calls the setter methods of form bean class in struts applications
struts
struts   Hi how struts flows from jsp page to databae and also using validation ? Thanks Kalins Naik
Struts
Struts  Hi i am new to struts. I don't know how to create struts please in eclipse help me
Struts
Struts   What is called properties file in struts? How you call the properties message to the View (Front End) JSP Pages
Struts
Struts  How Struts is useful in application development? Where to learn Struts? Thanks   Hi, Struts is very useful in writing web... performance Java web applications that runs on Java enabled application servers. Struts
struts
struts  which is the best book to study struts on own? please tell me   You can learn struts through the following books: 1)Programming Jakarta Struts By Chuck Cavaness 2)Professional Jakarta Struts By James Goodwill
struts
struts  which is the best book to study struts on own? please tell me   You can learn struts through the following books: 1)Programming Jakarta Struts By Chuck Cavaness 2)Professional Jakarta Struts By James Goodwill
struts
struts  how to start struts?   Hello Friend, Please visit the following links: http://www.roseindia.net/struts/ http://www.roseindia.net... can easily learn the struts. Thanks
Struts
Struts   1)in struts server side validations u are using programmatically validations and declarative validations? tell me which one is better ? 2) How to enable the validator plug-in file
Struts
Struts  Am newly developed struts applipcation,I want to know how to logout the page using the strus   Please visit the following link: Struts Login Logout Application
struts
struts  hi i would like to have a ready example of struts using "action class,DAO,and services" for understanding.so please guide for the same. thanks  Please visit the following link: Struts Tutorials
Struts - Struts
Struts for beginners  struts for beginners example
 

 

 

DMCA.com