Welcome Guest, Not a member yet? Register   Sign In
Validate input fields with dynamic names
#2

[eluser]Prophet[/eluser]
Okay I might have just found a solution to my own problem. It definitely works but is it good coding practice to do things like this?

Creating the inputs:
Code:
<input name="count_<?=$stock['id']?>" value="<?=$stock['count']?>" size="3" />

Form validation:
Code:
foreach ($_POST as $key => $val)
{
    if (substr($key, 0, 6) == 'count_')
    {
        $this->form_validation->set_rules($key, 'Count', 'required|is_natural|maxlength[7]');
    }
}


Messages In This Thread
Validate input fields with dynamic names - by El Forum - 05-19-2010, 05:27 AM
Validate input fields with dynamic names - by El Forum - 05-19-2010, 05:33 AM



Theme © iAndrew 2016 - Forum software by © MyBB