PHP Script Forums » PHP Classes Support Forum

How to add radio button to validation script 1.35?

(7 posts)
Please support us by buying these products:

  1. User has not uploaded an avatar

    johnpro
    Member

    It seems that it constantly shows me an error message as data will not be correct.

    I kindly ask you to send me instructions how o fix this issue.

    I have put the following into FORM:
    <td class="text_form1"><input name="vatidcon" type="radio" value="1" checked="checked" /></td>
    <td class="text_form1"><input name="vatidcon" type="radio" value="0" /></td>

    and above into validator:
    $example->add_text_field("VATID", $_POST['vatidcon'], "radio", "y");

    Why it shows and error that input is not valid?
    I noticed there are tow possibilities: checkbox and radio button.

    I kindly ask you to help me soon as possible.

    Posted 7 months ago #
  2. Olaf

    Olaf
    PHP Coder

    it must be:

    $example->add_check_box("some_name", "fieldname", "radio");

    Posted 7 months ago #
  3. User has not uploaded an avatar

    johnpro
    Member

    Hi I have done, but still message error 12.
    Is there some obligation for values in form. I have currently two values:
    <td><input name="vatidcon" type="radio" value="1" checked="checked" /></td>
    <td><input name="vatidcon" type="radio" value="0" /></td>

    and validation code:
    break;
    case "checkbox":
    case "radio":
    if (!$this->check_check_box($val['value'], $key, $val['element'])) {
    $status++;
    }

    and
    function add_check_box($name, $element_name, $type = "radio", $required_value = "n") {
    $this->fields[$name]['value'] = $required_value;
    $this->fields[$name]['type'] = $type;
    $this->fields[$name]['element'] = $element_name;
    }

    and
    function check_check_box($req_value, $field, $element) {
    if (empty($_REQUEST[$element])) {
    $this->messages[] = $this->error_text(12, $field);
    return false;
    } else {
    if (!empty($req_value)) {
    if ($req_value != $_REQUEST[$element]) {
    $this->messages[] = $this->error_text(12, $field);
    return false;
    } else {
    return true;
    }
    } else {
    return true;
    }
    }
    }

    It reports error 12:
    $msg[12]

    Posted 7 months ago #
  4. User has not uploaded an avatar

    johnpro
    Member

    I have change as you advised me:
    $example->add_text_field("some_name", $_POST['vatidcon'], "radio");

    Posted 7 months ago #
  5. Olaf

    Olaf
    PHP Coder

    Quote from: johnpro
    "I have change as you advised me:
    $example->add_text_field("some_name", $_POST['vatidcon'], "radio");"

    you didn't, check my previous post

    Posted 7 months ago #
  6. User has not uploaded an avatar

    johnpro
    Member

    Hi,
    I'm sorry I do not understand what you mean. Please explain more.Is issue code and what is wrong?

    Posted 7 months ago #
  7. Olaf

    Olaf
    PHP Coder

    do you see the difference?

    $example->add_text_field("some_name", $_POST['vatidcon'], "radio"); (wrong)

    and

    $example->add_check_box("some_name", "fieldname", "radio"); (OK)

    Posted 7 months ago #

RSS feed for this topic

Reply

You must log in to post.