how do i connect and validate javascript and java servlet
I have created a form on html and getting a textbox text to servlet for processing ,now my开发者_运维问答 confusion is how can i connect and validate that form using jquery and java servlet.
Anybody help me in this
Hmmm... without some code and more specific detail on what you need, I can only give you some hints. You can use something like the following code to validate your form on the client side:
<form id="someForm" action="someURL">
<input id="input1" type="text" value=""/>
<input id="input2" type="text" value=""/>
...
<input id="inputn" type="text" value=""/>
</form>
<script type="text/javascript">
$("#someForm").submit(function(){
var valid = true;
if ($("#input1").val() == "") {
alert("Please enter information for input1");
valid = false; // prevent the form from being submitted
} // use else, if put more conditions here
return valid;
});
</script>
Hope it helps!
精彩评论