Skip to content

Commit

Permalink
Merge pull request #19 from thunder123456/pokemon-form-validation
Browse files Browse the repository at this point in the history
prevent users from entering "all"
  • Loading branch information
versx authored Dec 28, 2020
2 parents be13940 + f2dd82a commit 770e8d1
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 6 deletions.
7 changes: 6 additions & 1 deletion src/views/pokemon-edit.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<form action="/api/pokemon/edit/{{id}}" method="post">
<div class="form-group">
{{Form}}
<input type="text" class="form-control" name="form" value="{{form}}" placeholder="i.e. Sunny">
<input type="text" class="form-control" name="form" value="{{form}}" placeholder="i.e. Sunny" pattern="^((?![aA][lL][lL]).)*$" id="pokemon_form">
</div>
<div class="form-group">
{{Minimum IV}}
Expand Down Expand Up @@ -67,6 +67,11 @@

<script type='text/javascript' src="/js/pokemon-list.js"></script>
<script type='text/javascript'>
var pokemon_form = document.getElementById('pokemon_form');
pokemon_form.oninvalid = function (event) {
event.target.setCustomValidity('Please leave blank if you want all pokemon forms');
}
$('#guild_id').val(guildId);
const guilds = document.querySelectorAll('*[id^="g_' + guildId + '"]');
if (guilds) {
Expand Down
7 changes: 6 additions & 1 deletion src/views/pokemon-new.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
</div>
<div class="form-group">
{{Form}}
<input type="text" class="form-control" name="form" value="" placeholder="i.e. Sunny">
<input type="text" class="form-control" name="form" value="" pattern="^((?![aA][lL][lL]).)*$" placeholder="i.e. Sunny" id="pokemon_form" >
</div>
<div class="form-group">
{{Minimum IV}}
Expand Down Expand Up @@ -91,6 +91,11 @@

<script type='text/javascript' src="/js/pokemon-list.js"></script>
<script type='text/javascript'>
var pokemon_form = document.getElementById('pokemon_form');
pokemon_form.oninvalid = function (event) {
event.target.setCustomValidity('Please leave blank if you want all pokemon forms');
}
$('#guild_id').val(guildId);
const guilds = document.querySelectorAll('*[id^="g_' + guildId + '"]');
if (guilds) {
Expand Down
6 changes: 5 additions & 1 deletion src/views/pvp-edit.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<form action="/api/pvp/edit/{{id}}" method="post">
<div class="form-group">
{{Form}}
<input type="text" class="form-control" name="form" value="{{form}}" placeholder="i.e. Sunny">
<input type="text" class="form-control" name="form" value="{{form}}" placeholder="i.e. Sunny" id="pokemon_form" pattern="^((?![aA][lL][lL]).)*$">
</div>
<div class="form-group">
{{League}}
Expand Down Expand Up @@ -54,6 +54,10 @@

<script type='text/javascript' src="/js/pokemon-list.js"></script>
<script type='text/javascript'>
var pokemon_form = document.getElementById('pokemon_form');
pokemon_form.oninvalid = function (event) {
event.target.setCustomValidity('Please leave blank if you want all pokemon forms');
}
$('#guild_id').val(guildId);
const guilds = document.querySelectorAll('*[id^="g_' + guildId + '"]');
if (guilds) {
Expand Down
6 changes: 5 additions & 1 deletion src/views/pvp-new.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
</div>
<div class="form-group">
{{Form}}
<input type="text" class="form-control" name="form" value="" placeholder="i.e. Sunny">
<input type="text" class="form-control" name="form" value="" placeholder="i.e. Sunny" id="pokemon_form" pattern="^((?![aA][lL][lL]).)*$">
</div>
<div class="form-group">
{{League}}
Expand Down Expand Up @@ -78,6 +78,10 @@

<script type='text/javascript' src="/js/pokemon-list.js"></script>
<script type='text/javascript'>
var pokemon_form = document.getElementById('pokemon_form');
pokemon_form.oninvalid = function (event) {
event.target.setCustomValidity('Please leave blank if you want all pokemon forms');
}
$('#guild_id').val(guildId);
const guilds = document.querySelectorAll('*[id^="g_' + guildId + '"]');
if (guilds) {
Expand Down
6 changes: 5 additions & 1 deletion src/views/raid-edit.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<form action="/api/raids/edit/{{id}}" method="post">
<div class="form-group">
{{Form}}
<input type="text" class="form-control" name="form" value="{{form}}" placeholder="i.e. Sunny">
<input type="text" class="form-control" name="form" value="{{form}}" placeholder="i.e. Sunny" pattern="^((?![aA][lL][lL]).)*$" id="pokemon_form">
</div>
<div class="form-group">
{{City}}
Expand All @@ -36,6 +36,10 @@
</div>

<script>
var pokemon_form = document.getElementById('pokemon_form');
pokemon_form.oninvalid = function (event) {
event.target.setCustomValidity('Please leave blank if you want all pokemon forms');
}
$('#guild_id').val(guildId);
const guilds = document.querySelectorAll('*[id^="g_' + guildId + '"]');
if (guilds) {
Expand Down
6 changes: 5 additions & 1 deletion src/views/raid-new.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
</div>
<div class="form-group">
{{Form}}
<input type="text" class="form-control" name="form" value="" placeholder="i.e. Sunny">
<input type="text" class="form-control" name="form" value="" placeholder="i.e. Sunny" pattern="^((?![aA][lL][lL]).)*$" id="pokemon_form">
</div>
<div class="form-group">
{{City}}
Expand All @@ -62,6 +62,10 @@

<script type='text/javascript' src="/js/pokemon-list.js"></script>
<script type='text/javascript'>
var pokemon_form = document.getElementById('pokemon_form');
pokemon_form.oninvalid = function (event) {
event.target.setCustomValidity('Please leave blank if you want all pokemon forms');
}
$('#guild_id').val(guildId);
const guilds = document.querySelectorAll('*[id^="g_' + guildId + '"]');
if (guilds) {
Expand Down

0 comments on commit 770e8d1

Please sign in to comment.