Activity Stream
48,167 MEMBERS
6801 ONLINE
besthostingforums On YouTube Subscribe to our Newsletter besthostingforums On Twitter besthostingforums On Facebook besthostingforums On facebook groups

Results 1 to 4 of 4
  1.     
    #1

    Exclamation form validation problem [help need]

    i want to validate a form field that is an array of input but is not working even input field is not showing
    please help me
    here is my form in php validation
    PHP Code: 
    <?php
    include("header.php");
    ?>
    <?php
        session_start
    ();
    $class=$_SESSION['class']=$_POST['class'];
    $sess=$_SESSION['session'] = $_POST['session'];
    $sub=$_SESSION['subject'] = $_POST['subject'];
    $term=$_SESSION['term'] = $_POST['term'];
    include(
    "config.php");
    $query="SELECT * FROM student_information WHERE class='$class'";
    $result mysql_query($query);
    $num_rows mysql_num_rows($result);

        
    // initialization
        
    $photo_upload_fields "";
        
    $counter 1;

        
    // default number of fields
        
    $number_of_fields $num_rows

    // If you want more fields, then the call to this page should be like, 
    // preupload.php?number_of_fields=20

        
    if( $_GET['number_of_fields'] )
        
    $number_of_fields = (int)($_GET['number_of_fields']);

        
    // Firstly Lets build the Category List
    echo"<h1>class:$class</h1>";
    echo
    "<br/>";
    echo
    "<h1>session:$sess</h1>";
    echo
    "<br/>";
    echo
    "<h1>subject:$sub</h1>";
    echo
    "<br/>";
    echo
    "<h1>term:$term</h1>";
    // Lets build the Photo Uploading fields
        
    while( $counter <= $number_of_fields )
        {
        
    $row1 mysql_fetch_row($result);
    $sid $row1['1'];
    $photo_upload_fields .=<<<__HTML_END
    <tr>
        <td>
              roll 
    {$counter}:<input name='marks[]' type='text' />// want to validate
              <input type='hidden' name='roll[]' value='
    $counter'/>
              
        </td>
    </tr>
    <tr>
        <td>
            <input name='sid[]' type='hidden' value='
    $sid'/>
        </td>
    </tr>
    <tr>
        <td>
             
        </td>
    </tr>
    <tr>
        <td>
             <input name='sub[]' type='hidden' value='
    $sub'/>
        </td>
    </tr>
    <tr>
        <td>
             <input name='sess[]' type='hidden' value='
    $sess'/>
        </td>
    </tr>
    <tr>
        <td>
             <input name='class[]' type='hidden' value='
    $class'/>
        </td>
    </tr>
    <tr>
        <td>
            <input name='term[]' type='hidden' value='
    $term'/>
        </td>
    </tr>
    __HTML_END;
        
    $counter++;
        }

    // Final Output
    echo <<<__HTML_END
    <html>
    <head>
        <title>insert classtest marks</title>
        <script language="JavaScript" type="text/javascript">
    <!--
    function checkform ( form )
    {
      if (form.marks.value == "") {
        alert( "Please enter marks." );
        form.marks.focus();
        return false ;
      } 
      // ** END **
      return true ;
    }
    //-->
    </script>
    </head>
    <body>
    <form  action='marksentry1.php' method='post' name='upload_form' onSubmit="return checkform(this);">
    <table width='90%' border='0' align='center' style='width: 90%;'>
    <tr>
        <td>
            <p>&nbsp;</p>
        </td>
    </tr>

    <!-Insert the photo fields here -->
    $photo_upload_fields

    <tr>
        <td>
                <input type='submit' name='submit' value='Add marks' />
        </td>
    </tr>
    </table>
    </form>
    </body>
    </html>
    __HTML_END;
    ?>
    shakac Reviewed by shakac on . form validation problem [help need] i want to validate a form field that is an array of input but is not working even input field is not showing please help me here is my form in php validation <?php include("header.php"); ?> <?php session_start(); $class=$_SESSION=$_POST; $sess=$_SESSION = $_POST; Rating: 5

  2.   Sponsored Links

  3.     
    #2
    Member
    Website's:
    imdber.org justpaste.me
    tr/td breaks the form. Try using div's instead.

  4.     
    #3
    thank apathetick for your fast reply
    please i tried it but form did not show
    please help

  5.     
    #4
    Respected Member
    Website's:
    DL4Everything.com Soft2050.in
    Replace checkform javascript function:
    PHP Code: 
    function checkform form )
    {
      if (
    form.marks.value == "") {
        
    alert"Please enter marks." );
        
    form.marks.focus();
        return 
    false ;
      } 
      
    // ** END **
      
    return true ;

    With:
    PHP Code: 
    function checkform form )
    {
      if (
    form.elements["marks[]"].value == "") {
        
    alert"Please enter marks." );
        
    form.elements["marks[]"].focus();
        return 
    false ;
      } 
      
    // ** END **
      
    return true ;

    This should work to validate the marks first.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Phone Validation
    By Myth? in forum Payza
    Replies: 3
    Last Post: 10th Mar 2012, 04:45 PM
  2. Form Validation, and AJAX APIs?
    By ciachn in forum Polling Plaza
    Replies: 0
    Last Post: 16th Feb 2012, 02:08 PM
  3. W3C validation? Does it really matter? Not always!
    By AriGold in forum Webmaster Discussion
    Replies: 3
    Last Post: 6th Jun 2011, 09:11 AM
  4. Problem using javascript in form field
    By abhikala1 in forum Web Development Area
    Replies: 4
    Last Post: 19th Apr 2011, 10:52 PM
  5. Feed Validation Problem??
    By Mulana in forum Technical Help Desk Support
    Replies: 0
    Last Post: 10th Apr 2011, 03:11 PM

Tags for this Thread

BE SOCIAL