By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,984 Members | 1,009 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,984 IT Pros & Developers. It's quick & easy.

function not calling by on click

P: 3
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="javascript">
function check()

{


$error_msg;
require_once('validation.class.php');

$obj = new validation();



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

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



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

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

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


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


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



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

$obj->add_fields($_POST['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="javascript"></script>

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


</head>
<title></title>
<body>
<form name="data" id="data" action="" method="post" enctype="multipart/form-data" onclick="check()">
<table align="center" border="1" width="50%" height="70%" >
<tr>
<td>First Name</td>
<td><input type="text" name="first_name" 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_birth"
onfocus="showCalendarControl(this);"
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="description" ></textarea>
</td>
</tr>
<tr>
<td colspan="2" align="center"><input type="submit" name="submit" value="submit" /></td>
</tr>
</table>







</form>

</body>

</html>
Oct 3 '11 #1
Share this Question
Share on Google+
2 Replies


100+
P: 1,059
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
Oct 4 '11 #2

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

thanks again for response
Oct 4 '11 #3

Post your reply

Sign in to post your reply or Sign up for a free account.