• Post Reply Bookmark Topic Watch Topic
  • New Topic

help me have a look at it  RSS feed

 
ruben chan
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i use jdk to compile the programe FormCheck.java.
i got 9 errors.but i have no idea about how to correct it.
i wish you could help me
thanks.

//this is a bean that will be used in my jsp page.
//CheckForm.java
package beans;
import java.awt.*;

public class CheckForm{
private String id;
private String pwd;
private String mail;
private boolean isRight;

public void setId(String id){
this.id=id;
}
public void setPWd(String pwd){
this.pwd=pwd;
}
public void setMail(String mail){
this.mail=mail;
}
public String getId(){
return id;
}

public String getPwd(){
return pwd;
}

public String getMail(){
return mail;
}

public boolean getResult(){
return isRight;
}
public void check(String id,String pwd){
if(checkId(id)&&checkPwd(pwd))
isRight=true;
else{
if(checkId(id)==false)
System.out.print("用户名输入不正确.");
if(!(checkPwd(pwd)))
System.out.print("密码输入不正确.");
}
}
public void check(String id,String Pwd,String rpwd,String mail){
if(checkId(id)&&checkPwd(pwd)&&check(rpwd)&&checkMail(mail))
isRight=true;
else{
if( !checkId(id))
System.out.print("用户名输入不正确。");
if( !checkPwd(pwd))
System.out.print("密码输入不正确.");
if( !(checkRpwd(rpwd))||pwd!=rpwd)
System.out.print("确认密码不正确。");
if( !(checkMail(mail)))
System.out.print("邮件格式不正确。");
}
}
private boolean checkId(String id){
boolean isOk;
int i=id.length();
if(i<=12){
for(int j=0;j<i;j++){
if(isDigit(id.charAt(j))||isAlpha(id.charAt(j)||(id.charAt(j).equals("_")&&(j!=0))))
isOk=true;
else
break;
}
}
return isOk;
}

private boolean checkPwd(String pwd){
int i=pwd.length();
boolean isOk;
if(i<=8){
for(int j=0;j<i;j++){
if(isDigit(pwd.charAt(j))||isAlpha(pwd.charAt(j)||(pwd.charAt(j).equals("_")&&j!=0)))
isOk=true;
else
break;
}
}
return isOk;
}

private boolean checkMail(String mail){
boolean isOk;
if(mail!=null){
int i=mail.length();
int a=mail.indexOf(i);
if(a!=-1&&a!=0&&a!=i-1){
for(int j=0;j<i;j++){
if(isDigit(mail.charAt(j))||isAlpha(mail.charAt(j)||(mail.charAt(j).equals("_")&&j!=0)))
isOk=true;
else
break;
}
}
}
return isOk;
}
private boolean isDigit(Char cCheck){
boolean isOk;
if(cCheck>="0"&&cCheck<="9")
isOk=true;
return isOk;
}
private boolean isAlpha(char cCheck){
boolean isOk;
if((('a'<=cCheck) && (cCheck<='z')) || (('A'<=cCheck) && (cCheck<='Z')))
isOk=true;
return isOk;
}
}
 
Bosun Bello
Ranch Hand
Posts: 1511
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What are the errors you are getting. Kind of hard to tell just by looking at the code.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!