I have a problem with loaded form. It doesn't trigger any events. Here's the form:
<form id ="form1" method="post" action="newjsp.jsp">
<h2>Form1</h2>
<p>
<span style="margin-left: 4px">Number:</span>
<input type="hidden" name="form_number" value="1"/>
<input class="textBox" type="text" name="number" value=""/>
</p>
<p>
<input id="the_button" type="submit" name="submit_button" value="Set"/>
</p>
</form>
I've tried basic examples with .on(), .live() and .delegate(), but none of those seems to work. I want to validate if number is 11 digits long. If not, stop submitting. Here's jQuery:
$("#form1").submit(function e(){
if($(".textbox").length != 11)
{
e.preventDefault();
$("#output").append("<p style='color:red;'>Please enter a valid number!</p>");
}
});
Thanks!