validation is working fine for me but i cant submit please help me
thanks
here is my php
Feyisa_1 0 Newbie Poster
<?php
include("../inc/header.php");
if($usertype != "Admin"){
header("Location: ../dashboard");
}
?>
<section class="side-menu fixed left">
<div class="top-sec">
<div class="dash_logo">
</div>
<p>Signature Record System</p>
</div>
<ul class="nav">
<li class="nav-item"><a href="../dashboard"><span class="nav-icon"><i class="fa fa-users"></i></span>All Employees</a></li>
<li class="nav-item"><a href="../dashboard/current_employees.php"><span class="nav-icon"><i class="fa fa-check"></i></span>Current Employees</a></li>
<li class="nav-item"><a href="../dashboard/past_employees.php"><span class="nav-icon"><i class="fa fa-times"></i></span>Past Employees</a></li>
<?php if($usertype == "Admin"){ ?>
<li class="nav-item current"><a href="../dashboard/add_employee.php"><span class="nav-icon"><i class="fa fa-user-plus"></i></span>Add Employee</a></li>
<li class="nav-item"><a href="../dashboard/add_user.php"><span class="nav-icon"><i class="fa fa-user"></i></span>Add User</a></li>
<?php } ?>
<li class="nav-item"><a href="../dashboard/settings.php"><span class="nav-icon"><i class="fa fa-cog"></i></span>Settings</a></li>
<li class="nav-item"><a href="../dashboard/logout.php"><span class="nav-icon"><i class="fa fa-sign-out"></i></span>Sign out</a></li>
</ul>
</section>
<section class="contentSection right clearfix">
<div class="displaySuccess"></div>
<div class="container">
<div class="wrapper add_employee clearfix">
<div class="section_title">Add Employee</div>
<form id="addemployee" class="clearfix" method="" action="">
<div class="section_subtitle">Personal Data</div>
<div class="input-box input-small left">
<label for="employee_id">Employee ID</label><br>
<input type="text" class="inputField emp_id" placeholder="Optional" name="employee_id">
<div class="error empiderror"></div>
</div>
<div class="input-box input-small right">
<label for="firstname">First Name</label><br>
<input type="text" class="inputField firstname" name="firstname">
<div class="error firstnameerror"></div>
</div>
<div class="input-box input-small left">
<label for="middlename">Middle Name</label><br>
<input type="text" class="inputField middlename" placeholder="Optional" name="middlename">
<div class="error middlenameerror"></div>
</div>
<div class="input-box input-small right">
<label for="lastname">Last Name</label><br>
<input type="text" class="inputField lastname" name="lastname">
<div class="error lastnameerror"></div>
</div>
<div class="input-box input-small left">
<label for="phone">Phone number</label><br>
<input type="text" class="inputField phone" name="phone">
<div class="error phoneerror"></div>
</div>
<div class="input-box input-small right">
<label for="phone">Signature number</label><br>
<input type="text" class="inputField signno" name="signno">
<div class="error signerror"></div>
</div>
<div class="input-box input-small left">
<label for="dateemployed">Date employed</label><br>
<input type="text" id="datepicker" class="inputField dateemployed" name="dateemployed">
<div class="error dateemployederror"></div>
</div>
<div class="input-box input-small right">
<label for="idtype">Employee Branch/Department</label><br>
<select class="inputField brname" name="brname">
<option value="">-- Select Branch/Department --</option>
<option value="Voter's">HR</option>
<option value="Passport">President Office</option>
<option value="NHIS">Finfinne Branch</option>
<option value="Driving License">Kersa Main Branch</option>
<div class="error depterror"></div>
</select>
<div class="error depterror"></div>
</div>
<div class="input-box input-small right">
<label for="idtype">Employee Category</label><br>
<select class="inputField empcat" name="empcat">
<option value="">-- Select Category --</option>
<option value="Voter's">President</option>
<option value="Passport">Vice President</option>
<option value="NHIS">Executive Director</option>
<option value="Driving License">Manager</option>
<option value="Driving License">CSM</option>
</select>
<div class="error empcaterror"></div>
</div>
<div class="input-box input-small left">
<label for="idtype">Signature Class</label><br>
<select class="inputField idtype" name="signtype">
<option value="">-- Select Signature Class --</option>
<option value="Voter's">A</option>
<option value="Passport">B</option>
<option value="NHIS">C</option>
<option value="Driving License">D</option>
</select>
</div>
<div class="input-box input-small left">
<label for="empstatus">Employment status</label><br>
<select class="inputField empstatus" name="empstatus">
<option value="">-- Select status --</option>
<option value="former">Former employee</option>
<option value="employee">Employee</option>
</select>
<div class="error empstatuserror"></div>
</div>
<div class="input-box input-upload-box right">
<div class="upload-wrapper">
<div class="upload-box">
<input type="file" name="nationalID" class="uploadField nationalID">
<div class="uploadfile nationalID_file">Upload Selected ID type</div>
<div class="filebtn nationID-btn">Upload</div>
<div class="filebtn nationID-disbtn">Upload</div>
</div>
</div>
<div class="error nationalIDerror"></div>
<div class="selected_nationalID_file"></div>
</div>
</div>
<div class="input-box">
<button type="submit" class="submitField">Add record</button>
</div>
</form>
</div>
</div>
</section>
<script type="text/javascript" src="../js/global.js"></script>
</body>
</html>
/*
Add Empolyee Form
*/
$("#addemployee").submit(function(e){
e.preventDefault();
var empiderror;
var firstnameerror;
var middlenameerror;
var lastnameerror;
var phoneerror;
var empcaterror;
var depterror;
var jobtypeerror;
var dateemployederror;
var photoerror;
var empstatuserror;
if($(".firstname").val() == ""){
firstnameerror = "Please enter employee first name";
} else if($.isNumeric($(".firstname").val()) && $(".firstname").val() != ""){
firstnameerror = "this field cannot contain numbers";
} else {
firstnameerror = "";
}
if($.isNumeric($(".middlename").val()) && $(".middlename").val() != ""){
middlenameerror = "this field cannot contain numbers";
} else {
middlenameerror = "";
}
if($(".lastname").val() == ""){
lastnameerror = "Please enter employee's lastname";
} else if($.isNumeric($(".lastname").val()) && $(".lastname").val() != ""){
lastnameerror = "this field cannot contain numbers";
} else {
lastnameerror = "";
}
if($(".phone").val() == ""){
phoneerror = "Please Enter phone number ";
} else if(!($.isNumeric($(".phone").val())) && $(".phone").val() != ""){
phoneerror = "this field cannot contain letters";
} else {
phoneerror = "";
}
if($(".empcat").val() == ""){
empcaterror = "Please enter employee category ";
} else {
empcaterror = "";
}
if($(".brname").val() == ""){
depterror = "Please enter employee Branch/department ";
} else {
depterror = "";
}
if($(".jobtype").val() == ""){
jobtypeerror = "Please enter Job type";
} else {
jobtypeerror = "";
}
if($(".dateemployed").val() == ""){
dateemployederror = "Please enter employment date";
} else {
dateemployederror = "";
}
if($(".empstatus").val() == ""){
empstatuserror = "Please select status of employee";
} else {
empstatuserror = "";
}
if($(".passport_file").html() == ""){
photoerror = "select a file and click upload";
} else {
photoerror = "";
}
if($(".selected_nationalID_file").html() == ""){
nationalIDerror = "select a file and click upload";
} else {
nationalIDerror = "";
}
$(".firstnameerror").html(firstnameerror);
$(".middlenameerror").html(middlenameerror);
$(".lastnameerror").html(lastnameerror);
$(".phoneerror").html(phoneerror);
$(".empcaterror").html(empcaterror);
$(".depterror").html(depterror);
$(".dateemployederror").html(dateemployederror);
$(".empstatuserror").html(empstatuserror);
$(".photoerror").html(photoerror);
$(".IDnumbererror").html(IDnumbererror);
if(firstnameerror == "" && middlenameerror == "" && lastnameerror == "" && phoneerror == "" && empcaterror == "" && depterror == "" && dateemployederror == "" && photoerror == "" && empstatuserror == "") {
$(".displaySuccess").css({
"margin-top":"0px",
"opacity":"1"
})
$(".displaySuccess").html('<span class="spinicon"><i class="fa fa-spinner fa-spin fa-1x fa-fw"></i></span> Adding new employee record');
$.ajax({
url: 'addemployee.php',
type: 'POST',
dataType: 'JSON',
data: {
firstname:$(".firstname").val(),
lastname: $(".lastname").val(),
middlename: $(".middlename").val(),
phone: $(".phone").val(),
signno: $(".signno").val(),
dateemployed: $(".dateemployed").val(),
brname: $(".brname").val(),
empcat: $(".empcat").val(),
signtype: $(".signtype").val(),
empstatus: $(".empstatus").val(),
nationalID: $(".nationalID").val(),
submit: 'submit'
},
success: function(data){
var status = (data.status);
if(status == "Success"){
$(".displaySuccess").html('<span class="spinicon"><i class="fa fa-check fa-1x"></i></span> Record added successfully')
setTimeout(function(){
$(".displaySuccess").css({
"margin-top":"",
"opacity":""
})
$(".displaySuccess").html('');
}, 5000)
} else if(status == "failed"){
$(".displaySuccess").css("background","#ff0000");
$(".displaySuccess").html('<span class="spinicon"><i class="fa fa-exclamation-circle fa-1x"></i></span> Error adding new record')
setTimeout(function(){
$(".displaySuccess").css({
"margin-top":"",
"opacity":"",
"background":""
})
$(".displaySuccess").html('');
}, 5000)
} else if(status == "exists"){
$(".displaySuccess").css("background","#ff0000");
$(".displaySuccess").html('<span class="spinicon"><i class="fa fa-exclamation-circle fa-1x"></i></span> Employee ID already exists')
setTimeout(function(){
$(".displaySuccess").css({
"margin-top":"",
"opacity":"",
"background":""
})
$(".displaySuccess").html('');
}, 5000)
}
}
})
}
})
Edited by Feyisa_1 because: change my code
- 1 Contributor
- 0 Replies
- 282 Views
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.