Welcome Guest, Not a member yet? Register   Sign In
form validation get field name
#1

[eluser]megabyte[/eluser]
I am working wiht a form, it has an array of text fields called names[]

Is there anyway to create a custom callback that I cna use to access which field is empty?

like if there are five input fields created using a loop

Code:
<input name="names[<?=$key?>]" type="text" value="<?=set_value('answer_text['.$key.']')?>" />

and I want to check which one is empty, and then write an error message saying

"please note name 3 cannot be empty"


is there a way to do it?


thanks
#2

[eluser]Skuja[/eluser]
You mean like this ?
Code:
<input name="names[]" type="text" value="<?=set_value(answer_text[$key])?>" />;
<?=form_error('names[]')?>;
#3

[eluser]megabyte[/eluser]
i guess i can do that, but i output all the validation errors at the top in an error div, so im looking for a way to i guess append to the validation object. I'll look into hacking it if i have to.




Theme © iAndrew 2016 - Forum software by © MyBB