2012-05-15 36 views
-3

我正在使用Struts的驗證功能。 因此,我想驗證移動號碼的每個數字必須是整數的10位數的手機號碼。我想驗證使用java代碼而不是javascript的手機號碼

我已經使用mobileno.contains()方法,但我沒有正確實現功能。

<tr> 
       <td align="left" valign="middle" nowrap><bean:message key="sp.mbno"/></td> 
       <td nowrap align="left" ><html:text property="mobileno" name="reg"/></td> 
      </tr> 
+0

爲什麼人們使其負。我需要這個:/ – Maninder

+3

downvotes的共振可能是因爲你沒有顯示研究工作。這樣的問題:我需要這個,給我代碼,往往會得到downvotes,但是像這樣的問題:「我需要這個,這是我已經嘗試過,並在這一行中有一個錯誤」會給你upvotes –

+0

@Jimmmy Gustafsson thanx表示你的關注。接下來我會處理這件事情。我會把我已經嘗試過的下一個tym的代碼.... – Maninder

回答

2
/* 
    * Returns true if string contains atlesat one alphabet(lowercase or uppercase). 
    */ 
    public static boolean containsAtLeastOneAlphabet(String str) 
    { 
     int x; 
     for(int j = 0 ; j < str.length() ; j++) 
     { 
      x = (int)str.charAt(j); 
      if((x >= 65 && x <= 90) || (x >= 97 && x <= 122)) 
       return true; 
     } 
     return false; 
    } 
+0

thanx解決我的問題。 – Maninder

+0

@ Ravi Jain Thanx我的問題也解決了:) – Maninder