163 lines
4.5 KiB
PHP
163 lines
4.5 KiB
PHP
|
<style>
|
||
|
form label.error, #secNameerr {
|
||
|
color : red;
|
||
|
}
|
||
|
</style>
|
||
|
<main class="wraper responsive-width" id="main">
|
||
|
<!----admin template Exam---->
|
||
|
<div class="admin_tempblock">
|
||
|
<div class="admin_tempsec">
|
||
|
<div class="admin_sec">
|
||
|
|
||
|
<form action="<?php echo base_url() ?>admin/ae-exam/<?php echo $id ?>" method="post" id="examForm">
|
||
|
|
||
|
<?php if($id == 0) {?>
|
||
|
<div class="subsec_sec">
|
||
|
<div class="subject_l">
|
||
|
<div class="subject_lsec">
|
||
|
<div class="subject_lhead"><?php echo $title ?></div>
|
||
|
<div class="subject_lformarea">
|
||
|
<div class="form-group">
|
||
|
<label for="">Exam Name<span class="text-danger font-weight-bold">*</span></label>
|
||
|
<input type="text" name="e_name" class="form-control" placeholder="Name of the exam">
|
||
|
<label id="secNameerr" style="display : none"></label>
|
||
|
</div>
|
||
|
<div class="form-group">
|
||
|
<label for="">Status<span class="text-danger font-weight-bold">*</span></label>
|
||
|
<select name="is_active" class="form-control">
|
||
|
<option selected disable value="">Choose exam status</option>
|
||
|
<option value="yes">Yes</option>
|
||
|
<option value="no">No</option>
|
||
|
</select>
|
||
|
</div>
|
||
|
<input type="submit" class="subject_addbtn" value="Save">
|
||
|
<a href="<?= base_url(); ?>admin/exam-view"><button type="button" class="subject_addbtn bg-dark ml-2">Back</button></a>
|
||
|
</div>
|
||
|
</div>
|
||
|
</div>
|
||
|
</div>
|
||
|
</form>
|
||
|
<?php } else { foreach ($result as $key => $value) {
|
||
|
?>
|
||
|
|
||
|
<div class="subsec_sec">
|
||
|
<div class="subject_l">
|
||
|
<div class="subject_lsec">
|
||
|
<div class="subject_lhead"><?php echo $title ?></div>
|
||
|
<div class="subject_lformarea">
|
||
|
<div class="form-group">
|
||
|
<label for="">Exam <span class="text-danger font-weight-bold">*</span></label>
|
||
|
<input type="text" name="e_name" value="<?php echo $value['e_name'] ?>" class="form-control" placeholder="Name of the exam">
|
||
|
<label id="secNameerr" style="display : none"></label>
|
||
|
</div>
|
||
|
<div class="form-group">
|
||
|
<label for="">Status<span class="text-danger font-weight-bold">*</span></label>
|
||
|
<select name="is_active" class="form-control">
|
||
|
<option selected value="<?php echo $value['is_active'] ?>"><?php echo $value['is_active'] ?></option>
|
||
|
<?php if($value['is_active'] == 'yes') { ?>
|
||
|
<option value="no">no</option>
|
||
|
<?php } else {?>
|
||
|
<option value="yes">yes</option>
|
||
|
<?php } ?>
|
||
|
</select>
|
||
|
</div>
|
||
|
|
||
|
<input type="submit" class="subject_addbtn" value="Update">
|
||
|
<a href="<?= base_url(); ?>admin/exam-view"><button type="button" class="subject_addbtn bg-dark ml-2">Back</button></a>
|
||
|
</div>
|
||
|
</div>
|
||
|
</div>
|
||
|
|
||
|
</div>
|
||
|
</form>
|
||
|
|
||
|
<?php } }?>
|
||
|
</div>
|
||
|
</div>
|
||
|
</div>
|
||
|
<!----admin template Exam end---->
|
||
|
</main>
|
||
|
<!--End right-top side-->
|
||
|
|
||
|
|
||
|
<script>
|
||
|
$(document).ready(function(){
|
||
|
|
||
|
jQuery.validator.addMethod("inputregx", function(value, element) {
|
||
|
return this.optional(element) || /^[a-zA-Z0-9 ]{3,50}$/.test(value);
|
||
|
}, 'Please enter alpha and numeric characters only ');
|
||
|
|
||
|
|
||
|
$("#examForm").validate({
|
||
|
|
||
|
rules: {
|
||
|
e_name: {
|
||
|
required: true,
|
||
|
inputregx: true,
|
||
|
minlength: 1
|
||
|
},
|
||
|
is_active : "required"
|
||
|
},
|
||
|
messages: {
|
||
|
|
||
|
e_name: {
|
||
|
required: "Please provide a Exam name",
|
||
|
minlength : "Please enter more than 4 Characters"
|
||
|
},
|
||
|
is_active : 'Please select the status of Exam'
|
||
|
|
||
|
},
|
||
|
submitHandler: function(form) {
|
||
|
|
||
|
var inputValue = $("input[name='e_name']",form).val();
|
||
|
inputValue = inputValue.toLowerCase();
|
||
|
|
||
|
let flag = false;
|
||
|
|
||
|
$.ajax({
|
||
|
url : '<?php echo base_url() ?>admin/check-exam-name',
|
||
|
data : {
|
||
|
value : inputValue
|
||
|
},
|
||
|
type : 'POST',
|
||
|
async : false,
|
||
|
success: function(data){
|
||
|
|
||
|
if (data == '[]') {
|
||
|
flag = true;
|
||
|
}
|
||
|
let response = JSON.parse(data);
|
||
|
|
||
|
$.each(response, function(key, value) {
|
||
|
let item = value['name'].toLowerCase();
|
||
|
if(inputValue === item) {
|
||
|
console.log('inside second');
|
||
|
flag = false;
|
||
|
return flag;
|
||
|
} else {
|
||
|
flag = true;
|
||
|
}
|
||
|
|
||
|
});
|
||
|
|
||
|
|
||
|
}
|
||
|
|
||
|
});
|
||
|
|
||
|
|
||
|
if(flag) {
|
||
|
form.submit();
|
||
|
} else {
|
||
|
$('#secNameerr').show();
|
||
|
$('#secNameerr').text('This Exam name already exists.');
|
||
|
}
|
||
|
|
||
|
|
||
|
}
|
||
|
});
|
||
|
|
||
|
});
|
||
|
</script>
|
||
|
|