2013-10-28 41 views
0

Jquery的形式過程中,我使用此腳本:由PHP情況下開關和驗證的動態字段

switch($id) { 

       //Username and real name need the same validation, so only need one case block here 
       case "titel": 
       case "graad": 
       case "info": 
       case "youtube": 
        //Ensure that they are both at least 6 characters long 
        if (strlen($value) < 6) { 
         //To make it more readable, replace the "-"'s with spaces and make the first character upper case 
         $msg = str_replace("-", " ", ucfirst($id)) . " moet minimaal 6 karakters lang zijn."; 
        } 
        break; 
       case "personen": 
       case "duur": 
        //Use PHP filter to validate the E-Mail address 
        if (!ctype_digit($value)) { 
         $msg = str_replace("-", " ", ucfirst($id)) . " mag alleen uit cijfers bestaan."; 
        } 
        break; 
       default: 

         $msg = ""; 

        break; 
      } 

我使用動態形式字段與名稱:nodig []和一個字段aantal []。問題是輸入字段是由id呈現的。

如何將動態字段放入交換機中?

網址與表格:http://www.rolfvandamme.nl/beta/(點擊橙色按鈕)。

對不起,我的英語不好。

+0

把你的代碼的函數裏面......並在foreach VAR後調用函數來驗證 – Hackerman

回答

0

你可以從文本框的值是這樣的:

<input type="text" name="array[]" /> 
<input type="text" name="array[]" /> 
<input type="text" name="array[]" /> 

$textbox_values_array = $_POST['array'];