Skip to content

Commit

Permalink
input box 빈칸 검출
Browse files Browse the repository at this point in the history
  • Loading branch information
1K3H committed Jul 10, 2020
1 parent 329b5f4 commit 9f488bb
Showing 1 changed file with 27 additions and 17 deletions.
44 changes: 27 additions & 17 deletions templates/index.html
Expand Up @@ -86,28 +86,38 @@
function save_node() {
let from_input = $('#from').val();
let to_input = $('#to').val();
$.ajax({
type: 'POST',
url: '/make',
data: {
'give_from_input': from_input,
'give_to_input': to_input,
'give_edge_id': from_input + to_input
},
success: function (response) {
if (response['result'] == 'success') {
window.location.reload();
};
}
});
// input 빈칸 검출
if (from_input == '') {
alert('FROM 값을 입력해 주세요.');
}
else if (to_input == '') {
alert('TO 값을 입력해 주세요.');
}
else {
$.ajax({
type: 'POST',
url: '/make',
data: {
'give_from_input': from_input,
'give_to_input': to_input,
'give_edge_id': from_input + to_input
},
success: function (response) {
if (response['result'] == 'success') {
window.location.reload();
};
}
});
};
};

</script>
</head>

<body>
<input id="from" type="text">
<input id="to" type="text">
<button onclick="save_node()" type="button">push</button>
<input id="from" type="text" placeholder="FROM">
<input id="to" type="text" placeholder="TO">
<button onclick="save_node()" type="button">CREATE</button>
<div id="cy"></div>
</body>

Expand Down

0 comments on commit 9f488bb

Please sign in to comment.