开发者

how do i connect and validate javascript and java servlet

开发者 https://www.devze.com 2023-03-31 04:38 出处:网络
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.

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!

0

精彩评论

暂无评论...
验证码 换一张
取 消