0

I using jquery.validate to validate my asp.net page. but when i got use submit, i got a perfect validate style like pic1 pic 1 with submit

but i need use button to save my data with ajax,so i try another way,like this

$(function() {

    $("#btns").click(function() {

        if ($('#form1').valid()) {

        }
    });
    });

the script was well work,but the high line of inoput was disappear and the result like this pic high line disappear and the error msg fllow the input i want to use button onclick function to trigger jquery validate , and use the first error style, how can i do? thx all

Sample Code like that.

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title></title>
<script src="../JS/jquery.js" type="text/javascript"></script>

    <script src="../JS/jquery.validate.js" type="text/javascript"></script>   
    <script language="javascript" type="text/javascript">
        $(function() {

        $("#btns").click(function() {

            if ($('#form1').valid()) {

            }
        });
        });
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:TextBox runat="server" ID="tbxEmail" type="email" name="email"></asp:TextBox>
            <input id="cemail" type="email" name="email" required />
                <input class="submit" type="submit" value="Submit"/>
                <input type="button" id="btns" value="btn"/>
    </div>
    </form>
</body>
</html>
BenMorel
  • 34,448
  • 50
  • 182
  • 322
willsonchan
  • 200
  • 2
  • 14
  • You need to add the necessary css styles to show the error styling on the fields. I don't see any styles added in your page, neither external nor inline. Are you sure you get the style mentioned in pic 1 when you click the submit button in the page rendered using the HTML you posted? – Sherin Mathew Jun 19 '14 at 10:56
  • 1
    You are confusing HTML5 validation (first picture) with the jQuery Validation plugin (second picture). When you're properly using the jQuery Validation plugin, all HTML5 validation is automatically disabled. – Sparky Jun 19 '14 at 14:28
  • See this: http://stackoverflow.com/a/22745621/594235 and this: http://stackoverflow.com/a/23087132/594235 – Sparky Jun 19 '14 at 14:33

0 Answers0