Skip to content

Commit 2392b77

Browse files
authored
Merge pull request #261 from wildan3105/fix/handle-only-space
fix: username cannot contain any space.
2 parents 9622700 + c4c1104 commit 2392b77

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

src/pages/partials/body.handlebars

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313
<form id="search-form" action="" method="get" action="#">
1414
<div class="input-group">
1515
<input type="text" class="form-control" autofocus="autofocus" id="username" name="username" placeholder="Github username"
16-
required>
17-
<button type="submit" class="input-group-addon btn" name="" onClick="showLoader();">
16+
required title="Username cannot be empty or contain only spaces">
17+
<button type="submit" class="input-group-addon btn" name="" onClick="return validateInput();">
1818
<i class="fa fa-search"></i>
1919
</button>
2020
</div>
@@ -103,3 +103,15 @@
103103
<script src="public/js/spinner.js"></script>
104104
<div id="fb-root"></div>
105105
<script src="public/js/social.js"></script>
106+
107+
<script>
108+
function validateInput() {
109+
const inputField = document.getElementById("username");
110+
if (/\s/.test(inputField.value)) {
111+
alert("Username cannot contain any spaces.");
112+
return false;
113+
}
114+
showLoader();
115+
return true;
116+
}
117+
</script>

0 commit comments

Comments
 (0)