Hope you all are fine . I have a problem my javascript function is not being called i dont know why
I am very confused why the function is not calling I used this same flow in my another form too that was also working fine but here Its a mess
Kinldy have a look on code and help me
Thanks
javascript:
function checkPriceValidation(){
var flight=document.getElementById('flightno').value;
var type=document.getElementById('type').value;
var price=document.getElementById('price').value;
if(flight==="volvo"){
alert("Please select flight number !!");
return false;
}
else if(type==="default"){
alert("Please select type!!");
return false;
}
else if(price===""){
alert("Please select the price !!");
return false;
}
return false;
}
html :
<form
class=""
method="post"
onsubmit="return javascript:checkPriceValidation();"
action="<%=response.encodeURL(request.getContextPath()+"/FillList")%>"
>
<div style="color:red;font-size:18px ">${error}</div>
<% session.setAttribute("error", "");%>
<table>
<tr>
<td>
<div class="form-control" style="width: auto">
<select style="color: black" name="flightno" >
<option value="volvo">Select Flight</option>
<%
ArrayList<FlightClass> list;
list = (ArrayList<FlightClass>) request.getSession().getAttribute("list");
for (FlightClass post : list) {
%>
<option><%=post.getID()%></option>
<% } %>
</select>
</div>
</td>
</tr>
<tr>
<td>
<div class="form-control" style="width: auto">
<select style="color: black" name="type">
<option value="default">Select Type</option>
<option>Economy</option>
<option>Business</option>
<option>First Class</option>
</select>
</div>
</td>
<td>
<input
type="number"
min="0"
step="1"
class="form-control"
name="price"
id="price"
placeholder="Price"
/>
</td>
</tr>
</table>
<br/>
<button input-type="submit" value="Submit" class="btn btn-lg btn-primary" >SET</button>
</form>
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…