dynamic server side validation!

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • pradeepjain
    Contributor
    • Jul 2007
    • 563

    dynamic server side validation!

    Hii guys,
    I am adding a few text boxes dynamically by using jquery add/remove button. say like prescription1,p rescription2 and so on. each prescription has 5 fields each co-related to each other . say like when he fills up prescription1 all fields must be entered or else none. how do i validate this.bcos i dono how many prescriptions are there earlier and its added dynamically!
  • gopher83
    New Member
    • Feb 2010
    • 2

    #2
    Array

    Hi!

    I think the most easiest way is to use an array for this. So, at client side, you will get like this:

    Code:
    <input type="text" name="prescriptions[0]" value="dsfasdf" />
    <input type="text" name="prescriptions[1]" value="dsfasdf" />
    <input type="text" name="prescriptions[2]" value="dsfasdf" />
    Then you can get this by the $_POST array:

    Code:
    $prescriptions = isset($_POST['prescriptions']) ? $_POST['prescriptions'] : array();
    And then use "foreach".

    Hope this helps.
    Last edited by Dormilich; Feb 23 '10, 02:28 PM. Reason: Please use [code] tags when posting code

    Comment

    Working...