JezK
Edit File: editContact.php
<?php $currentPage="editContact"; include("header.php"); include("app/getContactDetails.php"); ?> <div id="page-wrapper"> <form enctype="multipart/form-data" action="app/editContactApp.php" onsubmit="return validate()" method="post"> <div class="container-fluid"> <!-- Page Heading --> <div class="row"> <div class="col-lg-12"> <h1 class="page-header"> <small>Edit Contact</small> </h1> </div> </div> <!-- /.row <div class="col-lg-12 text-right"> <input type="button" value="Add Contact" class="btn btn-default add_button"> </div> --> <div class="row wrapper" > <div class="col-md-12 " > <div class="form-group row"> <label class="col-md-2">Name</label> <input type="hidden" value="<?php echo $contactID; ?>" name="contactID"> <input type="tex" class="cs-textfield col-md-4" placeholder="" name="name" id="name" value="<?php echo $name; ?>" autofocus> </div> <div class="form-group row"> <label class="col-md-2">Designation</label> <input type="tex" class="cs-textfield col-md-4" placeholder="" name="designation" id="designation" value="<?php echo $designation; ?>"> </div> <div class="form-group row"> <label class="col-md-2">Mobile Number</label> <input type="tex" class="cs-textfield col-md-4" placeholder="" maxlength="10" name="mobile" id="mobile" value="<?php echo $mobile; ?>" onkeypress="return number(event)"> </div> <div class="form-group row"> <label class="col-md-2">Landline Number</label> <input type="tex" class="cs-textfield col-md-4" placeholder="" maxlength="15" name="landline" id="landline" value="<?php echo $landline; ?>" onkeypress="return number(event)"> </div> </div> </div> <div class="col-md-12 text-center"> <input type="submit" value="Submit" name="submit" id="submit" class="btn btn-cs"> </div> <!-- /.row --> </div> <!-- /.container-fluid --> </form> </div> <!-- /#page-wrapper --> <script> function validate() { var name = document.getElementById('name'); var designation = document.getElementById('designation'); var mobile = document.getElementById('mobile'); var landline = document.getElementById('landline'); // Allow only alphabets and space var namePattern = /^[A-Za-z ]+$/; if(name.value.trim() == '') { alert("Please enter name."); name.focus(); return false; } // ❌ Block special characters if (!namePattern.test(name.value.trim())) { alert("Name should contain only alphabets and space. Special characters are not allowed."); name.focus(); return false; } if(designation.value.trim() == '') { alert("Please enter designation."); designation.focus(); return false; } if(mobile.value.trim() == '') { alert("Please enter mobile number."); mobile.focus(); return false; } if(landline.value.trim() == '') { alert("Please enter landline number."); landline.focus(); return false; } return true; } function number(e) { var key = e.keyCode || e.charCode; if(key == 13 || key == 43 || (key >= 48 && key <= 57) || key == 8 || key == 46) { return true; } else { return false; } } </script> <?php include("footer.php");?>