You are on page 1of 3

public boolean phonecheck(String phone){

if(phone.length()!=11){
JOptionPane.showMessageDialog(null, "Please, the phone number isn't 11
.");
return false;
}
if(!phone.startsWith("01")){
JOptionPane.showMessageDialog(null, "Please, the phone number isn't
Start with 01 .");
return false;
}
if(!phone.startsWith("010")||!phone.startsWith("011")||!phone.startsWith
("012")){
JOptionPane.showMessageDialog(null, "Please, the phone number isn't
011 or 012 or 010 .");
return false;
}
for(int i=3 ; i<phone.length(); i++){
if(!Character.isDigit(phone.charAt(i))){
JOptionPane.showMessageDialog(null, "Please, the phone number isn'
t digit .");
return false;
}
}
return true;
}
-------------------------------------------------------------------------------------public boolean uservalid(String user){
if(user.length()<5){
JOptionPane.showMessageDialog(null, "Please, the username isn't > 5 .
");
return false;
}
else{
if(Character.isLetter(user.charAt(0))){
for(int i=1 ; i<user.length(); i++){
if(!Character.isLetter(user.charAt(i)) && !Character.isDigit(
user.charAt(i))){
JOptionPane.showMessageDialog(null, "Please, the username mu
st contains just letters .");
return false;
}
}
}
else{
JOptionPane.showMessageDialog(null, "Please, the username must
starts with letter .");
return false;

}
return true;
}
}
public boolean passvalid(String password){
int upper=0,lower=0,digit=0;
if(password.length()<8){
JOptionPane.showMessageDialog(null, "Please, the password isn't > 8 .
");
return false;
}
else{
for(int i=0 ; i<password.length();i++){
if(Character.isUpperCase(password.charAt(i))){
upper++;
}
if(Character.isLowerCase(password.charAt(i))){
lower++;
}
if(Character.isDigit(password.charAt(i))){
digit++;
}
}
if(upper>=1&&lower>=1&&digit>=1){
// JOptionPane.showMessageDialog(null, "2"+upper+" "+lower+" "+digit+"
");
return true;
}else{
JOptionPane.showMessageDialog(null, "3"+upper+" "+lower+" "+digit
+" ");
return false;
}
}

}
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------public boolean namevalid(String name){
if(name.length()<10){
JOptionPane.showMessageDialog(null, "Please, the name must be more
than 10 letters .");
return false;
}
if(Character.isLetter(name.charAt(0))){
for(int i=1 ; i<name.length(); i++){
if(!Character.isLetter(name.charAt(i)) && !name.contains(" ")
){
JOptionPane.showMessageDialog(null, "Please, the username mu
st contains just letters .");
return false;
}
}
}

return true;
}
---------------------------------------------------------------------------------------------public boolean nationalvalid(String natid){
if(natid.length()!=14){
JOptionPane.showMessageDialog(null, "Please, the national ID must be 14
numbers ");
return false;
}
for(int i=1 ; i<natid.length(); i++){
if(!Character.isDigit(natid.charAt(i))){
JOptionPane.showMessageDialog(null, "Please, the national ID must be
only numbers ");
return false;
}
}
return true;
}
---------------------------------------------------------------public boolean licencevalid(String licence){
if(licence.length()!=6){
JOptionPane.showMessageDialog(null, "Please, the licence must be 6 numb
ers ");
return false;
}
for(int i=0 ; i<licence.length(); i++){
if(!Character.isDigit(licence.charAt(i))){
JOptionPane.showMessageDialog(null, "Please, the licence must be onl
y numbers ");
return false;
}
}
return true;
}

You might also like