diff --git a/public/profil_edit.js b/public/profil_edit.js new file mode 100644 index 0000000000000000000000000000000000000000..7aac010d5d37dd3c40cb6ca18bc9288de45d137c --- /dev/null +++ b/public/profil_edit.js @@ -0,0 +1,11 @@ +function validateProfileEdit() { + var inputName = document.getElementById('inputName').value; + var inputPhone = document.getElementById('inputPhone').value; + + if (inputName.trim() == "" || inputPhone.trim() == "") { + alert("Name and Phone can't empty!"); + return false; + } + + return true; +} \ No newline at end of file diff --git a/src/view/profil_edit.php b/src/view/profil_edit.php index c0150991299e02b82663aa6c1a66659b79065f94..d991cdd6d35da54b03b7b47672688c98ae2afc1b 100644 --- a/src/view/profil_edit.php +++ b/src/view/profil_edit.php @@ -15,7 +15,7 @@ </div> </div> <div class="row"> - <form action="/main/profil/edit/save?u=<?=$id?>" method="post" enctype="multipart/form-data"> + <form action="/main/profil/edit/save?u=<?=$id?>" method="post" enctype="multipart/form-data" onsubmit="return validateProfileEdit()"> <div class="container" style="width: 65%"> <div class="row"> <div class="col-6 text-left"> @@ -39,7 +39,7 @@ Your Name </div> <div class="col-4 line-height-medium"> - <input style="width: 100%; height: 30px;padding-left: 5px;font-size: medium" type="text" name="name" value="<?=$user->name?>"> + <input id="inputName" style="width: 100%; height: 30px;padding-left: 5px;font-size: medium" type="text" name="name" value="<?=$user->name?>"> </div> </div> <div class="row"> @@ -47,7 +47,7 @@ Phone </div> <div class="col-4 line-height-medium"> - <input style="width: 100%; height: 30px;padding-left: 5px;font-size: medium" type="text" name="phone" value="<?=$user->phone?>"><br> + <input id="inputPhone" style="width: 100%; height: 30px;padding-left: 5px;font-size: medium" type="text" name="phone" value="<?=$user->phone?>"><br> </div> </div> <div class="row" style="margin-top: 5px"> @@ -56,7 +56,7 @@ </div> <div class="col-4 line-height-medium text-right"> <label class="switch"> - <input type="checkbox" name="isDriver" <?=$user->isDriver ? 'checked' : ''?>> + <input id="inputDriver" type="checkbox" name="isDriver" <?=$user->isDriver ? 'checked' : ''?>> <span class="slider round"></span> </label> </div> @@ -75,5 +75,6 @@ </form> </div> </div> +<script type="text/javascript" src="/profil_edit.js"></script> </body> </html> \ No newline at end of file