remove mobile number validation : venkateshwaran

This commit is contained in:
venkateswaran ubuntu 2023-07-04 09:51:24 +05:30
parent dec9bf31c2
commit 637fe3db2f
12 changed files with 141 additions and 132 deletions

View File

@ -26,28 +26,30 @@
oFReader.onload = function (oFREvent) {
document.getElementById("uploadPreview").src = oFREvent.target.result;
};
};
function checkno_if_exists() {
var mobile_no = $("#mno").val();
$('#mobErr').hide();
};
//do not delete this part
$.ajax({
type:"post",
url: "<?php echo base_url(); ?>EmployeeController/mno_validation",
data:{ mobile_no:mobile_no},
success:function(response)
{
// function checkno_if_exists() {
// var mobile_no = $("#mno").val();
// $('#mobErr').hide();
// $.ajax({
// type:"post",
// url: "<?php echo base_url(); ?>EmployeeController/mno_validation",
// data:{ mobile_no:mobile_no},
// success:function(response)
// {
if (response == true)
{
$('#mobErr').show();
$('#mobErr').html("This mobile number already exists");
$("#mno").val('');
}
}
});
}
// if (response == true)
// {
// $('#mobErr').show();
// $('#mobErr').html("This mobile number already exists");
// $("#mno").val('');
// }
// }
// });
// }
@ -209,6 +211,27 @@ if (companyName == '') {
}
function validateKeyPress(event) {
var key = event.key;
var allowedCharacters = /^[A-Za-z._/-]$/;
if (!allowedCharacters.test(key)) {
event.preventDefault();
}
}
function validateName(event) {
const charCode = event.which || event.keyCode;
const char = String.fromCharCode(charCode);
// Regular expression to match alphanumeric characters
const regex = /^[a-zA-Z0-9_-]*$/;
if (!regex.test(char)) {
event.preventDefault();
return false;
}
}
</script>
</head>
@ -254,27 +277,27 @@ if (companyName == '') {
</div>
<div class="col-sm-6">
<label>Employee ID<span class="error">*</span></label>
<input type="text" name="emp_code" id="empid" onkeyup="checkemp_if_exists()" required/><span id="empidErr" class="error"></span>
<input type="text" name="emp_code" id="empid" onkeyup="checkemp_if_exists()" onkeypress="return validateName(event)" required/><span id="empidErr" class="error"></span>
</div>
<div class="col-sm-6">
<label>Employee Name<span class="error">*</span></label>
<input type="text" name="emp_name" id="name" onkeypress = "return match(event)" required/><span id="nameErr" class="error"></span>
<input type="text" name="emp_name" id="name" onkeypress="validateKeyPress(event)" required/><span id="nameErr" class="error"></span>
</div>
<div class="col-sm-6">
<label>Designation<span class="error">*</span></label>
<input type="text" name="emp_desg" id="emp_desg" onkeypress = "return matchdesg(event)" required/><span id="degsErr" class="error"></span>
<input type="text" name="emp_desg" id="emp_desg" onkeypress="validateKeyPress(event)" required/><span id="degsErr" class="error"></span>
</div>
<div class="col-sm-6">
<label>Mobile Number<span class="error">*</span></label>
<input type="tel" id="mno" onkeypress = "return matchnum(event)" name="emp_mobile" pattern="[6-9][0-9]{9}" id="emp-mobile" minlength="10" maxlength="10" onkeyup ="checkno_if_exists()" onchange=" return num(event)"SSSS
required/>
<label>Mobile Number</label>
<input type="tel" id="mno" onkeypress = "return matchnum(event)" name="emp_mobile" pattern="[6-9][0-9]{9}" id="emp-mobile" minlength="10" maxlength="10" onchange=" return num(event)"/>
<span id="mobErr" class="error"></span>
<!-- onkeyup ="checkno_if_exists()" -->
</div>
</div>
<div class="row mb-3">
<div class="col-sm-6">
<label>Email<span class="error">*</span></label>
<input type="email" id="email" name="emp_email" pattern="[a-z0-9._%+-]+@[a-z0-9.-]+\.[a-z]{2,}$]" id="" placeholder="Employee E-mail" onkeyup="check_if_exists()" required/>
<input type="email" id="email" name="emp_email" pattern="[a-z0-9._%+-]+@[a-z0-9.-]+\.[a-z]{2,}$]" id="" onkeyup="check_if_exists()" required/>
<span id="emailErr" class="error"></span>
</div>
<div class="col-sm-4">
@ -293,7 +316,8 @@ if (companyName == '') {
</form>
</div>
</section>
<!-- Footer -->
<!-- Footer -->
<script>
$(document).ready(function() {
@ -329,46 +353,6 @@ $(document).ready(function() {
<script>
// $('#companyName').on('change', function () {
// $('#comp_Err').html('')
// });
// $('#empid').on('change', function () {
// $('#empidErr').html('')
// });
// $('#name').on('change', function () {
// $('#nameErr').html('')
// });
// $('#emp_desg').on('change', function () {
// $('#degsErr').html('')
// });
// $('#mno').on('change', function () {
// $('#mobErr').html('')
// });
// $('#email').on('change', function () {
// $('#emailErr').html('')
// });
// $('#uploadImage').on('change', function () {
// $('#imgErr').html('')
// });
// function check_if_exists() {
// var code = $("#empid").val();
// $.ajax({
// type:"post",
// url: "<?php echo base_url(); ?>EmployeeController/check_emp_code",
// data:{ code:code},
// success:function(response)
// {
// if (response == true)
// {
// alert("This mail id already exists");
// // $("#email").val('');
// }
// }
// });
// }
$(document).ready(function() {
$('#companyName').on('change', function() {
var companyName = $('#companyName').val();
@ -420,17 +404,17 @@ $(document).ready(function() {
$('#mno').on('keyup', function() {
var mno = $('#mno').val();
if ($('#mno').val().length == 0)
{
$('#mobErr').text('Please Enter a MobileNumber.');
}
else
{
$('#mobErr').text('');
}
});
// $('#mno').on('keyup', function() {
// var mno = $('#mno').val();
// if ($('#mno').val().length == 0)
// {
// $('#mobErr').text('Please Enter a MobileNumber.');
// }
// else
// {
// $('#mobErr').text('');
// }
// });
$('#email').on('keyup', function() {
var email = $('#branch_name').val();
@ -485,10 +469,10 @@ $(document).ready(function() {
errorFound = true;
}
if (mno == '') {
$('#mobErr').text('Enter Employee MobileNumber.');
errorFound = true;
}
// if (mno == '') {
// $('#mobErr').text('Enter Employee MobileNumber.');
// errorFound = true;
// }
if (email == '') {
$('#emailErr').text('Enter Employee Email-Id.');

View File

@ -22,7 +22,34 @@
document.getElementById("uploadPreview").src = oFREvent.target.result;
};
};
</script>
</script>
<script>
function validateName(event) {
const charCode = event.which || event.keyCode;
const char = String.fromCharCode(charCode);
// Regular expression to match alphanumeric characters
const regex = /^[a-zA-Z0-9_-]*$/;
if (!regex.test(char)) {
event.preventDefault();
return false;
}
}
</script>
<script>
function validateKeyPress(event) {
var key = event.key;
var allowedCharacters = /^[A-Za-z._/-]$/;
if (!allowedCharacters.test(key)) {
event.preventDefault();
}
}
</script>
</head>
<body>
<!-- Header -->
@ -89,20 +116,20 @@
</div>
<div class="col-sm-6">
<label>Employee ID<span class="error">*</span></label>
<input type="text" onkeyup="checkemp_if_exists()" id="emp_code" name="emp_code" value="<?php echo $row->emp_code; ?>" class="disabled" required /><span id="empidErr" class="error"></span>
<input type="text" onkeyup="checkemp_if_exists()" onkeypress="return validateName(event)" id="emp_code" name="emp_code" value="<?php echo $row->emp_code; ?>" class="disabled" required /><span id="empidErr" class="error"></span>
</div>
<div class="col-sm-6">
<label>Employee Name<span class="error">*</span></label>
<input type="text" name="emp_name" value="<?php echo $row->emp_name; ?>" required />
<input type="text" name="emp_name" onkeypress="validateKeyPress(event)" value="<?php echo $row->emp_name; ?>" required />
</div>
<div class="col-sm-6">
<label>Designation<span class="error">*</span></label>
<input type="text" name="emp_desg" value="<?php echo $row->emp_desg; ?>" required />
<input type="text" name="emp_desg" onkeypress="validateKeyPress(event)" value="<?php echo $row->emp_desg; ?>" required />
</div>
<div class="col-sm-6">
<label>Mobile Number<span class="error">*</span></label>
<label>Mobile Number</label>
<input type="tel" onkeypress = "return matchnum(event)" pattern="[6-9]{1}[0-9]{9}"
title="Phone number with 6-9 and remaing 9 digit with 0-9" name="emp_mobile" value="<?php echo $row->emp_mobile; ?>" required/>
title="Phone number with 6-9 and remaing 9 digit with 0-9" name="emp_mobile" value="<?php echo $row->emp_mobile; ?>"/>
</div>
</div>
<div class="row mb-3">
@ -199,39 +226,6 @@ function comp_branch(){
});
// $(document).ready(function() {
// $('.ct').change(function() {
// var comp_id = $(this).val();
// if (comp_id != '') {
// $.ajax({
// url: '<?php echo base_url('EmployeeController/get_branch'); ?>',
// type: 'post',
// data: {comp_id: comp_id},
// dataType: 'json',
// success: function(response) {
// console.log(response)
// var len = response.length;
// // $('.st').empty();
// var arr = [];
// for (var i = 0; i < len; i++) {
// var branch_name = response[i]['branch_name'];
// var branch_id = response[i]['branch_id'];
// data = "<option value='"+branch_id+"'>"+branch_name+"</option>";
// arr.push(data);
// }
// $('.st').html(arr);
// // $('.st').html('arr');
// }
// });
// } else {
// $('.ct').empty();
// $('.ct').append("<option value=''> Select city </option>");
// }""
// });
// });
// age & mobile number (only number)
function matchnum(event)
{

View File

@ -6,7 +6,9 @@
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Montserrat:wght@500;600;700&display=swap" rel="stylesheet">
<link rel="stylesheet" href="<?php echo base_url('assets/style.css'); ?>">
<link rel="stylesheet" href="<?php echo base_url('assets/style.css'); ?>">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.4/jquery.min.js"></script>
</head>
<body>
<div class="main-section empview-section">
@ -29,14 +31,16 @@
<?php echo $view->comp_name; ?>
</div>
<div class="employee-details">
<div class="employee-whatsapp">
<?php if($view->emp_mobile != "") { ?>
<div class="employee-whatsapp">
<div class="icon">
<img src="<?php echo base_url(); ?>/assets/images/Whatsapp-icon.png">
</div>
<div class="details">
<a href="https://api.whatsapp.com/send?phone=91<?php echo $view->emp_mobile; ?>" target="_blank">WhatsApp me</a>
<a id="<?php echo $view->emp_mobile; ?>" href="https://api.whatsapp.com/send?phone=91<?php echo $view->emp_mobile; ?>" target="_blank">WhatsApp me</a>
</div>
</div>
<?php } ?>
<div class="employee-email">
<div class="icon">
<img src="<?php echo base_url(); ?>/assets/images/Email-icon.png">
@ -61,17 +65,29 @@
<a href="<?php echo $view->maplink; ?>" target="_blank"><?php echo $view->branch_address; ?></a>
</div>
</div>
<div class="emp-btn">
<div class="emp-save">
<a href="<?php echo base_url('EmployeeController/vcard');?>?id=<?php echo $view->emp_id;?>" class="button"><img src="<?php echo base_url(); ?>/assets/images/CTA-Save-icon.png"/> Save </a>
</div>
<?php if($view->emp_mobile == "") { ?>
<div class="emp-btn" style="justify-content:center;">
<div class="emp-share">
<button id="shareBtn" class="button"><img src="<?php echo base_url(); ?>/assets/images/CTA-Share-icon.png"/> Share</button>
<script async src="https://static.addtoany.com/menu/page.js"></script>
</div>
</div>
</div>
<?php } else {?>
<div class="emp-btn">
<div class="emp-save" >
<a id=save_button href="<?php echo base_url('EmployeeController/vcard');?>?id=<?php echo $view->emp_id;?>" class="button"><img src="<?php echo base_url(); ?>/assets/images/CTA-Save-icon.png"/ > Save </a>
</div>
<div class="emp-share">
<button id="shareBtn" class="button"><img src="<?php echo base_url(); ?>/assets/images/CTA-Share-icon.png"/> Share</button>
<script async src="https://static.addtoany.com/menu/page.js"></script>
</div>
</div>
<?php } ?>
</div>
</div>
</div>
@ -132,6 +148,19 @@ function siteURL() {
alert("Browser doesn't support this API !");
}
})
</script>
</script>
<!-- <script>
$(document).ready(function() {
var empMobile = "<?php echo $view->emp_mobile ?>";
if (empMobile == "") {
$('#save_button').css('display', 'none');
}
});
</script> -->
</body>
</html>

View File

@ -48,6 +48,7 @@
<?php echo $view->comp_name; ?>
</div>
<div class="employee-details">
<?php if($view->emp_mobile != "") { ?>
<div class="employee-whatsapp">
<div class="icon">
<img src="<?php echo base_url(); ?>/assets/images/Whatsapp-icon.png">
@ -56,6 +57,7 @@
<a href="https://api.whatsapp.com/send?phone=91<?php echo $view->emp_mobile; ?>" target="_blank">WhatsApp me</a>
</div>
</div>
<?php } ?>
<div class="employee-email">
<div class="icon">
<img src="<?php echo base_url(); ?>/assets/images/Email-icon.png">

BIN
uploads/1688366103.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 460 KiB

BIN
uploads/16883661031.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 460 KiB

BIN
uploads/1688373610.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.1 KiB

BIN
uploads/16883736101.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.1 KiB

BIN
uploads/1688373792.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 73 KiB

BIN
uploads/16883737921.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 73 KiB

BIN
uploads/1688374144.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 73 KiB

BIN
uploads/16883741441.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 73 KiB