function not calling by on click

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • amit yogi
    New Member
    • Oct 2011
    • 3

    function not calling by on click

    hi , i am making a form of user registratin and using server side validation. but function is not working on click. please suggest...





    <html>
    <head>

    <script language="javas cript">
    function check()

    {


    $error_msg;
    require_once('v alidation.class .php');

    $obj = new validation();



    $obj->add_fields($_P OST['first_name'], 'req', 'Please Enter First Name');
    $obj->add_fields($_P OST['first_name'], 'name', 'Please Enter valid First Name');

    $obj->add_fields($_P OST['last_name'], 'req', 'Please Enter Last Name');
    $obj->add_fields($_P OST['last_name'], 'name', 'Please Enter valid Last Name');



    $obj->add_fields($_P OST['interest'], 'check', 'Please select your interest');

    $obj->add_fields($_P OST['gender'], 'req', 'Please select Gender');

    $obj->add_fields($_P OST['date_birth'], 'req', 'Please Enter Birth Date');


    $obj->add_fields($_P OST['email'], 'req', 'Please Enter Email Address');
    $obj->add_fields($_P OST['email'], 'email', 'Enter valid Email Address');


    $obj->add_fields($_P OST['phone_no'], 'req', 'Please Mobile Number Required');
    $obj->add_fields($_P OST['phone_no'], 'mobile', 'Invalid Mobile No');
    $obj->add_fields($_P OST['phone_no'], 'max=10', 'Mobile No. should not be more than 10 characters long');



    $obj->add_fields($_P OST['description'], 'req', 'Please Enter description');

    $obj->add_fields($_P OST['description'], 'max=200', 'Address should not be more than 200 characters long');


    $error = $obj->validate();

    if($error){
    echo "<font color='#FF0000' family='verdana ' size=2>".$error ."</font>";

    }
    else
    {
    $error_msg=1;
    }

    }
    </script>

    <?php
    if(isset($error _msg)){

    include('submit .php');

    }
    ?>
    <link href="css/CalendarControl .css"
    rel="stylesheet " type="text/css">
    <script src="js/CalendarControl .js"
    language="javas cript"></script>

    <link href="css/calendar.css" rel="stylesheet " type="text/css">


    </head>
    <title></title>
    <body>
    <form name="data" id="data" action="" method="post" enctype="multip art/form-data" onclick="check( )">
    <table align="center" border="1" width="50%" height="70%" >
    <tr>
    <td>First Name</td>
    <td><input type="text" name="first_nam e" id="letters" />
    </td>
    </tr>
    <tr>
    <td>Last Name</td>
    <td><input type="text" name="last_name " id ="letters1" />
    </td>
    </tr>
    <tr>
    <td>Interest</td>
    <td><input type="checkbox" name="interest[]" id="interest" value="game"/>Game
    <input type="checkbox" name="interest[]" id="interest" value="study"/>study
    <input type="checkbox" name="interest[]" id="interest" value="journey"/>journey
    <input type="checkbox" name="interest[]" id="interest" value="art"/>art
    </td>
    </tr>
    <tr>
    <td>Gender</td>
    <td><input type="radio" name="gender" value="male" />male
    <input type="radio" name="gender" value="female"/>female</td>
    </tr>
    <tr>
    <td>
    D.O.B.
    </td>
    <td> <input name="date_birt h"
    onfocus="showCa lendarControl(t his);"
    type="text" readonly />
    </td>
    </tr>
    <tr>
    <td>Email: </td>
    <td><input type="text" name="email" size="30" value=""></td>
    </tr>
    <tr>
    <td>Phone No</td>
    <td><input type="text" name="phone_no" id="phone"/></td>
    </tr>
    <tr>
    <td>
    Image
    </td>
    <td><input type="file" name="image" id="image" /></td>
    </tr>
    <tr>
    <td>
    Description
    </td>
    <td>
    <textarea cols="20" rows="5" name="descripti on" ></textarea>
    </td>
    </tr>
    <tr>
    <td colspan="2" align="center"> <input type="submit" name="submit" value="submit" /></td>
    </tr>
    </table>







    </form>

    </body>

    </html>
    Last edited by amit yogi; Oct 3 '11, 01:07 PM. Reason: forget
  • johny10151981
    Top Contributor
    • Jan 2010
    • 1059

    #2
    USE CODE BLOCK

    and form dont have any action name OnClick. Only Input type object may have onclick, I am saying may have because Select object with single height dont work on onclick

    Comment

    • amit yogi
      New Member
      • Oct 2011
      • 3

      #3
      thanks, but i heard from sone one function onclick is not working in same page...

      thanks again for response

      Comment

      Working...