Commit 5a68acfe authored by Wildan Dicky Alnatara's avatar Wildan Dicky Alnatara
parents 51123760 b4591d73
......@@ -15,3 +15,28 @@ td {
textarea {
width: 100%;
}
/*Tooltip*/
.tooltiptext {
width: 120px;
background-color: black;
color: #fff;
text-align: center;
border-radius: 6px;
padding: 5px 0;
position: absolute;
z-index: 1;
top: -5px;
left: 110%;
}
.tooltiptext::after {
content: "";
position: absolute;
top: 50%;
right: 100%;
margin-top: -5px;
border-width: 5px;
border-style: solid;
border-color: transparent black transparent transparent;
}
\ No newline at end of file
......@@ -4,6 +4,7 @@
font-size: 28px;
font-family: 'Nunito', sans-serif;
padding: 5px;
margin-block-end: 30px;
}
.fivestar-rating {
......
function validateForm(){
// alert('Here 2');
//alert('Here 2');
pp = document.getElementById("profpict").value;
name = document.getElementById("name").value;
address = document.getElementById("address").value;
......
const BLANK_FIELD = "field must be filled.";
const INVALID_EMAIL_FORMAT = "invalid email format.";
const INVALID_NAME_LENGTH = "name exceeded 20 characters.";
const INVALID_PHONENUMBER_FORMAT = "please enter numbers only.";
const INVALID_PHONENUMBER_LENGTH = "please enter valid phone number (9 - 12 digits).";
const UNMATCHED_PASSWORD = "unmatched password and confirmed password.";
const EMAIL_REGEX = /^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/;
const BLANK_SPACE_REGEX = /^\s*$/
const NUMBER_REGEX = /^[0-9]*$/
function getFieldValue(inputID) {
return document.getElementById(inputID).value;
}
function validateBlankInput(inputID) {
var value = getFieldValue(inputID);
if (value == "" || BLANK_SPACE_REGEX.test(value)) {
showInvalidInput(inputID + BLANK_FIELD, inputID);
return false;
} else {
hideInvalidInput(inputID);
return true;
}
}
function validateBlankPassword() {
var validation = true;
validation &= validateBlankInput("password-input");
validation &= validateBlankInput("confpassword-input");
return validation == 1;
}
//Match password and confirmed password
function validatePassword() {
function validateAllPasswords() {
var pass = document.forms["registrationform"]["password"].value;
var conf_pass = document.forms["registrationform"]["conf_password"].value;
if (validateBlankPassword()) {
if (pass != conf_pass) {
alert("Unmatched password and confirmed password");
alert(UNMATCHED_PASSWORD);
highlightInvalidInput("password-input");
highlightInvalidInput("confpassword-input");
return false;
} else {
hideInvalidInput("password-input");
hideInvalidInput("confpassword-input");
return true;
}
} else {
return false;
}
}
function validateName() {
if (validateBlankInput("name-input")) {
if (getFieldValue("name-input").length > 20) {
showInvalidInput(INVALID_NAME_LENGTH, "name-input");
return false;
} else {
hideInvalidInput("name-input");
return true;
}
} else {
return false;
}
}
function validateAccount($input) {
var checkTick = document.getElementById("validate_" + $input).innerHTML;
function validatePhoneNumber() {
if (validateBlankInput("phonenumber-input")) {
if (NUMBER_REGEX.test(getFieldValue("phonenumber-input"))) {
var getLength = getFieldValue("phonenumber-input").length;
if (getLength >= 9 && getLength <= 12) {
hideInvalidInput("phonenumber-input");
return true;
} else {
showInvalidInput(INVALID_PHONENUMBER_LENGTH, "phonenumber-input");
return false;
}
} else {
showInvalidInput(INVALID_PHONENUMBER_FORMAT, "phonenumber-input")
}
} else {
return false;
}
}
function validateUsername() {
if (validateBlankInput("username-input")) {
return validateAvailability("username");
} else {
return false;
}
}
function validateEmail() {
if (validateBlankInput("email-input")) {
re = EMAIL_REGEX;
var checkFormat = re.test(String(getFieldValue("email-input")).toLowerCase());
if (!checkFormat) {
showInvalidInput(INVALID_EMAIL_FORMAT, "email-input");
return false;
}
else {
return validateAvailability("email");
}
} else {
return false;
}
}
function validateAddress() {
if (validateBlankInput("address-input")) {
return true;
} else {
return false;
}
}
function validateAvailability(input) {
var checkTick = document.getElementById("validate_" + input).innerHTML;
if (checkTick == "") {
alert($input + " is unavailable!");
showInvalidInput(input + " is unavailable!", input+"-input");
return false;
} else {
hideInvalidInput(input+"-input");
return true;
}
}
function submitValidation() {
var validation = true;
validation &= validateAccount("username");
validation &= validateAccount("email");
validation &= validatePassword();
validation &= validateName();
validation &= validateUsername();
validation &= validateEmail();
validation &= validateAllPasswords();
validation &= validateAddress();
validation &= validatePhoneNumber();
return validation == 1;
}
......@@ -46,3 +155,25 @@ function checkUserAvailability(input, str) {
xmlhttp.send();
}
}
function showInvalidInput(message, inputID) {
var message = message.replace(/-input/, " ");
var message = message.replace(/conf/, "confirmed ");
alert(message);
highlightInvalidInput(inputID);
}
function highlightInvalidInput(inputID) {
var border = document.getElementById(inputID).style.border;
if (border == "") {
document.getElementById(inputID).style.border = "2px solid red";
}
}
function hideInvalidInput(inputID) {
//document.getElementById("address-input").style.visibility = "hidden";
var border = document.getElementById(inputID).style.border;
if (border == "2px solid red") {
document.getElementById(inputID).style.border = "";
}
}
\ No newline at end of file
......@@ -48,12 +48,12 @@
return '<table align="center">
<tr>
<td>Name</td>
<td><input type="text" size="25" name="name" required ></td>
<td><input id="name-input" type="text" size="25" name="name"></td>
</tr>
<tr>
<td>Username</td>
<td>
<div id="validate_form"><input type="text" size="21" name="username" onkeyup="checkUserAvailability(\'username\', this.value)" required > </div>
<div id="validate_form"><input id="username-input" type="text" size="21" name="username" onkeyup="checkUserAvailability(\'username\', this.value)"> </div>
<!--<div id="validate_icon"><img src="../svgIcon/tick.png"></div>-->
<span id="validate_username"></div>
</td>
......@@ -61,25 +61,26 @@
<tr>
<td>Email</td>
<td>
<div id="validate_form"><input type="email" size="21" name="email" onkeyup="checkUserAvailability(\'email\', this.value)" required ></div>
<div id="validate_form"><input id="email-input" type="text" size="21" name="email" onkeyup="checkUserAvailability(\'email\', this.value)"></div>
<span id="validate_email"></div>
</td>
</tr>
<tr>
<td>Password</td>
<td><input type="password" size="25" maxlength="16" name="password" required ></td>
<td><input id="password-input" type="password" size="25" maxlength="16" name="password">
</td>
</tr>
<tr>
<td>Confirm Password</td>
<td><input type="password" size="25" maxlength="16" name="conf_password" required ></td>
<td><input id="confpassword-input" type="password" size="25" maxlength="16" name="conf_password"></td>
</tr>
<tr>
<td>Address</td>
<td><textarea name="address" rows="3" cols="28" required ></textarea></td>
<td><textarea id="address-input" name="address" rows="3" cols="28"></textarea></td>
</tr>
<tr>
<td>Phone Number</td>
<td><input type="text" size="25" name="phonenumber" required ></td>
<td><input id="phonenumber-input" type="text" size="25" name="phonenumber"></td>
</tr>
</table>';
}
\ No newline at end of file
......@@ -41,7 +41,7 @@
}
public static function validateOrderHistory($order_id, $user_id) {
$listOfHistoryID = selectFromWhere('Nomor_Order', 'book_order', 'user_id='.$user_id.' AND has_reviewed=0');
$listOfHistoryID = selectFromWhere('Nomor_Order', 'book_order', 'user_id='.$user_id);
foreach ($listOfHistoryID as $hist) {
if ($hist == $order_id) {
return TRUE;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment