I'm trying to validate on the client side using javascript. (.js) However , the asp file doesn't seem to reach the javascript file even thought I linked the path in the head.

<head runat="server">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title>Acceuil</title>
    <link href="styles.css" rel="stylesheet" />
    <script src="js/validation.js" type='text/javascript'></script>
</head>

Validator:

<asp:CustomValidator runat="server"
                        ID="CustomValidatorJava"
                        ClientValidationFunction="ClientValidateMatricule"
                        ErrorMessage="Le format du matricule est incorrect"
                        ControlToValidate="txtBoxMatricule"
                        ValidateEmptyText="True"
                        EnableClientScript="True" BackColor="Black" ForeColor="White">
                    </asp:CustomValidator>

js file:

function ClientValidateMatricule(source, arguments)
{
    if (arguments.Value.length == 7) {
        var cpt = 0;
        for (var i = 0; i < arguments.Value.length; i++) {
            if (isNaN(arguments[i])) {
                arguments.isValid = false;
                break;
            } else if ((!isNaN(arguments[i]))) {
                cpt++;
            }
        }

        if (cpt == arguments.Value.length) {
            arguments.isValid = true;
        }
    } else {
        arguments.isValid = false;
    }
}

Also if I put a break point in the JS file while the debug is running, a yellow triangle appears on the point saying it won't reach because no symbol has been charged.

Related posts

Recent Viewed