Модальное окно покажет сообщение об успехе, если форма пуста, без проверки данных в таблице в Laravel.Php

Кемеровские программисты php общаются здесь
Ответить Пред. темаСлед. тема
Anonymous
 Модальное окно покажет сообщение об успехе, если форма пуста, без проверки данных в таблице в Laravel.

Сообщение Anonymous »

Проблема в том, что модальное окно покажет сообщение об успехе, даже если форма пуста. Я хочу получать сообщение об успехе только в том случае, если данные, введенные в базу данных, в противном случае показывают сообщение об ошибке. вот моя страница с клинком. Для этого используется концепция репозитория. Данные вставляются в БД. Проблема в модальном режиме Bootstrap. я хочу получать сообщение об успехе, только если данные вставлены в базу данных. В противном случае отображается сообщение об ошибке.






Document




@import url("https://fonts.googleapis.com/css2?famil ... splay=swap");

* {
margin: 0;
padding: 0;
box-sizing: border-box;
font-family: "Poppins", sans-serif;
}

:root {
--main-blue: #71b7e6;
--main-purple: #9b59b6;
--main-grey: #ccc;
--sub-grey: #d9d9d9;
}
body {
display: flex;
height: 100vh;
justify-content: center;
/*center vertically */
align-items: center;
/* center horizontally */
background: linear-gradient(135deg, var(--main-blue), var(--main-purple));
padding: 10px;
}

/* container and form */
.container {
max-width: 700px;
width: 100%;
background: #fff;
padding: 25px 30px;
border-radius: 5px;
}

.container .title {
font-size: 25px;
font-weight: 500;
position: relative;
}

.container .title::before {
content: "";
position: absolute;
height: 3.5px;
width: 30px;
background: linear-gradient(135deg, var(--main-blue), var(--main-purple));
left: 0;
bottom: 0;
}

.container form .user__details {
display: flex;
flex-wrap: wrap;
justify-content: space-between;
margin: 20px 0 12px 0;
}

/* inside the form user details */
form .user__details .input__box {
width: calc(100% / 2 - 20px);
margin-bottom: 15px;
}

.user__details .input__box .details {
font-weight: 500;
margin-bottom: 5px;
display: block;
}

.user__details .input__box input {
height: 45px;
width: 100%;
outline: none;
border-radius: 5px;
border: 1px solid var(--main-grey);
padding-left: 15px;
font-size: 16px;
border-bottom-width: 2px;
transition: all 0.3s ease;
}

.user__details .input__box input:focus,
.user__details .input__box input:valid {
border-color: var(--main-purple);
}

/* inside the form gender details */

form .gender__details .gender__title {
font-size: 20px;
font-weight: 500;
}

form .gender__details .category {
display: flex;
width: 80%;
margin: 15px 0;
justify-content: space-between;
}

.gender__details .category label {
display: flex;
align-items: center;
}

.gender__details .category .dot {
height: 18px;
width: 18px;
background: var(--sub-grey);
border-radius: 50%;
margin: 10px;
border: 5px solid transparent;
transition: all 0.3s ease;
}

#dot-1:checked~.category .one,
#dot-2:checked~.category .two,
#dot-3:checked~.category .three {
border-color: var(--sub-grey);
background: var(--main-purple);
}

form input[type="radio"] {
display: none;
}

/* submit button */
form .button {
height: 45px;
margin: 45px 0;
}

form .button input {
height: 100%;
width: 100%;
outline: none;
color: #fff;
border: none;
font-size: 18px;
font-weight: 500;
border-radius: 5px;
background: linear-gradient(135deg, var(--main-blue), var(--main-purple));
transition: all 0.3s ease;
}

form .button input:hover {
background: linear-gradient(-135deg, var(--main-blue), var(--main-purple));
}

@media only screen and (max-width: 584px) {
.container {
max-width: 100%;
}

form .user__details .input__box {
margin-bottom: 15px;
width: 100%;
}

form .gender__details .category {
width: 100%;
}

.container form .user__details {
max-height: 300px;
overflow-y: scroll;
}

.user__details::-webkit-scrollbar {
width: 0;
}
}







$(document).ready(function() {

// $('#myModal').modal('show');
$("#registrationForm").submit(function(e) {
e.preventDefault();
var data = $("#registrationForm").serialize();
//alert("hello");
var pathurl = $("#url").val();
$.ajax({
url: pathurl + 'demouser', // Laravel route for store method
type: "POST",
data: {
_token: $('meta[name="csrf-token"]').attr('content'),
data: data
},

success: function(response) { //controller response
console.log("Data added successfully!");
console.log(response); //controller response
if (response.message == 'Item added successfully') {
//alert("hi");
$('#myModal').css("display", "show");
//$('#registrationForm').trigger('reset');
$('#registrationForm')[0].reset();
}
},
error: function(xhr, status, error) {
console.error("Error:", error);
}
});
})
});








×

Sucess message

Your registration is completed..

Close








Registration





Full Name


Username


Email


Phone Number


Password







Gender



Male



Female



Prefer not to say














Подробнее здесь: https://stackoverflow.com/questions/785 ... he-data-in
Реклама
Ответить Пред. темаСлед. тема

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

  • Похожие темы
    Ответы
    Просмотры
    Последнее сообщение

Вернуться в «Php»