0
I need to validate the inputs of a form. I am working with JSP, javascript and html codes. The system is expected to work like this: The person buys and has the purchase steps. In the 1st stasis, the person puts the quantity, then when clicking on the "Continue" button, he must validate if the user has filled that quantity field, otherwise he won’t let go to the next step. I tried to do this with form and it didn’t work very well. It would be possible to do this validation by javascript or some command within html?
Code
<ul class="nav nav-tabs" role="tablist">
<li role="presentation" class="active">
<a href="#step1" data-toggle="tab" aria-controls="step1" role="tab" title="" data-original-title="PRODUTO" aria-expanded="true">
<span class="round-tab">
<p align="center"><img src="images/p1.png" height="60" width="60"></p>
</span>
</a>
</li>
<li role="presentation" class="disabled">
<a href="#step2" data-toggle="tab" aria-controls="step2" role="tab" title="" data-original-title="ENVIO" aria-expanded="false">
<span class="round-tab">
<p align="center"><img src="images/p2.png" height="60" width="60"></p>
</span>
</a>
</li>
</ul>
<div class="tab-content">
<div class="tab-pane active" role="tabpanel" id="step1">
<div class="step1">
<div class="row">
<div class="preview col-md-6">
<p align="center"><img src="images/xbox.png" height="300" width="200"></p>
</div>
<div class="col-xs-5">
<h2>Dados do Produto</h2>
<table style="width:100%">
<tr>
<td>Produto</td>
<td><%=anuncio.getTitulo()%></td>
</tr>
<tr>
<td>Qtd. disponivel: </td>
<td><%=anuncio.getQuantidade()%></td>
</tr>
<tr>
<td>Qtd. desejada: </td>
<td><input type="text" id="quantity" name="quantity" value="1" disabled="disabled" size="4" required></td>
</tr>
<tr>
<td>Valor Unitario: </td>
<td><%=anuncio.getPreco()%></td>
</tr>
</table>
<ul class="list-inline pull-right">
<li><input type="button" class="btn btn-primary next-step" value="CONTINUAR"></li>
</ul>
</div>
</div>
</div>
</div>
</div>
Good afternoon buddy, see if this helps your problem: https://www.revisa-programar.info/artigos/validaca-de-formularios-em-javascript/
– Felipe Miranda
It didn’t help me much, because there is a form, and the form makes the information go to another page. In my case it would not work, because all the steps are on the same page (page that contains "tabs", in which are the steps), if I leave and go back to page, the order of the steps starts again, losing the filled data
– Celina Shigetomi