Can I improve my validation?

Posted by Qmal on Stack Overflow See other posts from Stack Overflow or by Qmal
Published on 2011-01-10T15:57:16Z Indexed on 2011/01/10 18:53 UTC
Read the original article Hit count: 104

Filed under:
|
|
|

So I want to validate my form using jQuery, this is how I imagine it and it works, but is the best method of doing it and maybe I can do it more effective with less code?

<script type="text/javascript">
    $(document).ready(function()
    {
        $("#frmCatAdd").submit(function()
        {
            var name = $("#edtName").val();

            if (name == "")
                $("#edtName").css("border", "1px solid red")
            else
                $("#frmCatAdd").submit();

            return false;
        });
    });
</script>

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about jQuery