Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7699039
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T22:23:07+00:00 2026-05-31T22:23:07+00:00

The problem is when i add custom checkbox , the valid function do not

  • 0

The problem is when i add custom checkbox , the valid function do not work, but i include the class= ‘require’ in my custom checkbox and the field id is correct. Either the custom selectbox or new add selectbox does not work. But when the custom selectbox are remove, and add new box , everything works fine

js:

    <script>
$(document).ready(function() {
   $('.remove').click(function(){
        $(this).parent().remove();
    });

    $("#add").click(function() {
        var intId = $("#configField div").length + 1;
        var label = $("<label>Field Name:</label>");
        var labelType = $("<label>Field Type:</label>");
        var labelReq = $("<label>Require:</label>");
        var labelTag = $("<label>Tag:</label>");
        var fieldWrapper = $("<div class=\"fieldwrapper\" id=\"field" + intId + "\"/>");
        var fName = $("<input type=\"text\" name=\"RName[]\" class=\"required\" />");
        var fTag = $("<input type=\"text\" name=\"Tag[]\" class=\"required\" />");
      **This is the require second select box**  var **fReq** = $("<select class=\"required\" name=\"Req[]\" ><option value=\"\">Please Select</option><option value=\"1\">Yes</option><option value=\"0\">No</option></select>");
        var fType = $("<select class=\"required\" name=\"RType[]\"  ><option value=\"\">Please Select</option><option value=\"txt\">Text</option><option value=\"int\">Numbers</option><option value=\"bool\">Boolean</option></select>");
        var removeButton = $("<input type=\"button\" class=\"remove\" value=\"Remove\" />");
        removeButton.click(function() {
            $(this).parent().remove();
        });

        fieldWrapper.append('<br>');        
        fieldWrapper.append(label);
        fieldWrapper.append(fName);
        fieldWrapper.append('<br>');
        fieldWrapper.append(labelType);
        fieldWrapper.append(fType);
        fieldWrapper.append('<br>');
        fieldWrapper.append(labelReq);
        fieldWrapper.append(fReq);
        fieldWrapper.append('<br>');
        fieldWrapper.append(labelTag);
        fieldWrapper.append(fTag);
        fieldWrapper.append('<br>');
        fieldWrapper.append(removeButton);
        $("#configField").append(fieldWrapper);
    });
});

</script>

html

    <?

if (isset ($_GET['id']))
{$list=$_GET['id'];
$_SESSION['editID']=$list;}
else
{$list=$_SESSION['editID'];}

    try{
$sql = '
    SELECT   *
    FROM     require_attributes
    WHERE    ListID=?
';
$stmt = $conn->prepare($sql);
$stmt->execute(array($list));
$result= $stmt->fetchAll();
}
catch(PDOException $e)
    {
    die ($e->getMessage().'<a href="view.php"> Back</a>'); 
    }

    $counter=1;

    foreach ($result as $set) 
{
?>

<div class='fieldwrapper' id=<? echo "field".$counter ?>><br>
<label>Field Name:</label><input type='text' name='RSSName[]' class='required' value=<? echo $set['Attribute']?>><br>
<label>Field Type:</label><select class='required' name='RType[]' <?if ($set['Attribute']=='Email') echo "disabled='disabled'";?>><option value=''>Please Select</option><option value='txt' <? if ($set['Type']=='txt') echo "SELECTED";?>>Text</option><option value='int' <? if ($set['Type']=='int') echo "SELECTED";?>>Numbers</option><option value=='bool' <? if ($set['Type']=='bool') echo "SELECTED";?>>Boolean</option></select><br>
      **This is the custom select box**
<label>Require:</label><select class='required' name='Req[]' <?if ($set['Attribute']=='Email') echo "disabled='disabled'";?>><option value=''>Please Select</option><option value='1' <? if ($set['Req']=='1') echo "SELECTED";?>>Yes</option><option value='0' <? if ($set['Req']=='0') echo "SELECTED";?>>No</option></select><br>
<label>Tag:</label><input type='text' name='Tag[]' class='required' value=<? echo $set['Tag']?>>
<?if ($set['Attribute']!='Email') echo "<br><input type='button' class='remove' value='Remove'>";?></div>

<?
$counter++;
}?>


</fieldset>
<input type="button" value="Add a field" class="add" id="add" />
<input type="submit" value="Submit">


</form>

</html>

Full page

<?
include("../connection/conn.php");
session_start();


if($_SERVER['REQUEST_METHOD'] == "POST"){

$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);


if (isset ($_GET['id']))
{$list=$_GET['id'];
$_SESSION['editID']=$list;}
else
{$list=$_SESSION['editID'];}

//For case only have email field.
if (!isset ($_POST['RType']) && !isset($_POST['Req']))
{
            try{

$sql = 'DELETE ra.* FROM require_attributes ra WHERE ListID = ?';

$stmt = $conn->prepare($sql);
$stmt->execute(array($list));
}
catch(PDOException $e)
    {
    die ($e->getMessage()."<a href='view.php' onClick='window.location.reload()'> Back</a>"); 
    }


    foreach ($_POST['Tag'] as $set) {
    $tag=$set;}

    try {
    $query="INSERT INTO require_attributes (ReqID,ListID,Attribute,Type,Req,Tag) VALUES ('',$list,'Email','txt',1,?)";
    $stmt = $conn->prepare($query);
    $stmt->execute(array($tag));

}
catch(PDOException $e)
    {
    die ($e->getMessage()."<a href='view.php' onClick='window.location.reload()'> Back</a>"); 
    } 
}   

//For case  have more than one field.
else
{
foreach ($_POST['RName'] as $input) {
    echo $input . PHP_EOL;
}
foreach ($_POST['Tag'] as $input) {
    echo $input . PHP_EOL;
}
foreach ($_POST['Req'] as $input) {
    echo $input . PHP_EOL;
}
foreach ($_POST['RType'] as $input) {
    echo $input . PHP_EOL;
}
}

?>
<div id="stylized" class="myform">
<div style="text-align:center;font-weight:bold;">You have successfully config the list. <a href='config.php'>Back</a></div>
<div class="spacer"></div>
</div>
<?
}else{?>



<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>

<script src="../plugin/jquery-1.6.1.min.js"></script>
<script src="../plugin/jquery.validate.min.js"></script>
<script src="../plugin/jquery.form.js"></script>
<link rel="stylesheet" type="text/css" href="../style/form.css" />





<!-- **********************This is validation function call**********************-->

    <script>
    $(document).ready(function(){
    $("#config").validate();
    });  
    </script>



    <script>
    $(document).ready(function() {
       $('.remove').click(function(){
            $(this).parent().remove();
        });

        $("#add").click(function() {
            var intId = $("#configField div").length + 1;
            var label = $("<label>Field Name:</label>");
            var labelType = $("<label>Field Type:</label>");
            var labelReq = $("<label>Require:</label>");
            var labelTag = $("<label>Tag:</label>");
            var fieldWrapper = $("<div class=\"fieldwrapper\" id=\"field" + intId + "\"/>");
            var fName = $("<input type=\"text\" name=\"RName[]\" class=\"required\" />");
            var fTag = $("<input type=\"text\" name=\"Tag[]\" class=\"required\" />");
            var fReq = $("<select  class=\"required\" name=\"Req[]\" ><option selected=\"\" value=\"\">Please Select</option><option value=\"1\">Yes</option><option value=\"0\">No</option></select>");
            var fType = $("<select  class=\"required\" name=\"RType[]\"  ><option selected=\"\" value=\"\">Please Select</option><option value=\"txt\">Text</option><option value=\"int\">Numbers</option><option value=\"bool\">Boolean</option></select>");
            var removeButton = $("<input type=\"button\" class=\"remove\" value=\"Remove\" />");
            removeButton.click(function() {
                $(this).parent().remove();
            });

            fieldWrapper.append('<br>');        
            fieldWrapper.append(label);
            fieldWrapper.append(fName);
            fieldWrapper.append('<br>');
            fieldWrapper.append(labelType);
            fieldWrapper.append(fType);
            fieldWrapper.append('<br>');
            fieldWrapper.append(labelReq);
            fieldWrapper.append(fReq);
            fieldWrapper.append('<br>');
            fieldWrapper.append(labelTag);
            fieldWrapper.append(fTag);
            fieldWrapper.append('<br>');
            fieldWrapper.append(removeButton);
            $("#configField").append(fieldWrapper);
        });
    });

    </script>



    </head>
    <body>

    <form id="config" method="post" action="config.php" >
    <fieldset id="configField">

        <?

    if (isset ($_GET['id']))
    {$list=$_GET['id'];
    $_SESSION['editID']=$list;}
    else
    {$list=$_SESSION['editID'];}

        try{
    $sql = '
        SELECT   *
        FROM     require_attributes
        WHERE    ListID=?
    ';
    $stmt = $conn->prepare($sql);
    $stmt->execute(array($list));
    $result= $stmt->fetchAll();
    }
    catch(PDOException $e)
        {
        die ($e->getMessage().'<a href="view.php"> Back</a>'); 
        }

        $counter=1;

        foreach ($result as $set) 
    {
    ?>
    <div class='fieldwrapper' id=<? echo "field".$counter ?>><br>
    <label>Field Name:</label><input type='text' name='RName[]' class='required' value=<? echo $set['Attribute']?>><br>
    <label>Field Type:</label><select class='required' name='RType[]' <?if ($set['Attribute']=='Email') echo "disabled='disabled'";?>><option selected="" value="">Please Select</option><option value='txt' <? if ($set['Type']=='txt') echo "SELECTED";?>>Text</option><option value='int' <? if ($set['Type']=='int') echo "SELECTED";?>>Numbers</option><option value=='bool' <? if ($set['Type']=='bool') echo "SELECTED";?>>Boolean</option></select><br>
    <label>Require:</label><select class='required' name='Req[]' <?if ($set['Attribute']=='Email') echo "disabled='disabled'";?>><option selected="" value="">Please Select</option><option value='1' <? if ($set['Req']=='1') echo "SELECTED";?>>Yes</option><option value='0' <? if ($set['Req']=='0') echo "SELECTED";?>>No</option></select><br>
    <label>Tag:</label><input type='text' name='Tag[]' class='required' value=<? echo $set['Tag']?>>
    <?if ($set['Attribute']!='Email') echo "<br><input type='button' class='remove' value='Remove'>";?></div>


    <?
    $counter++;
    }?>


    </fieldset>
    <input type="button" value="Add a field" class="add" id="add" />
    <input type="submit" value="Submit">


    </form>

    </html>

    <?
    }
    ?>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T22:23:09+00:00Added an answer on May 31, 2026 at 10:23 pm

    Basicly its because Validator dosen’t support input array names it seems.

    Creataed a working example here: http://jsfiddle.net/hawat/2/

    You fix this with some editing of the validator plugin, see:
    JQuery Validation for Array of Input Elements

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

The problem Add custom validation to a form field in Django 1.3, the form
I can add a normal rightBarButton to my navigation without a problem but now
I'm having a problem trying to add a custom HTML5 data attribute to the
I am trying to add a custom image to a checkbox and I'm using
Been trying to add custom post type which was successful the problem i am
I have a problem to add custom methods to my models. I found solution
I need to extend the TreeNode class such that I can add custom properties
I have problem to add jQuery to some existing code, please help. We have
I have a problem: I've add a Jquery UI drag-n-drop widget to my page,
I'm experiencing this problem: I want to add the Google Maps API to my

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.