sábado, 20 de septiembre de 2014

validacion texto

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>Kendo UI Snippet</title>

    <link rel="stylesheet" href="http://cdn.kendostatic.com/2014.2.716/styles/kendo.common.min.css">
    <link rel="stylesheet" href="http://cdn.kendostatic.com/2014.2.716/styles/kendo.rtl.min.css">
    <link rel="stylesheet" href="http://cdn.kendostatic.com/2014.2.716/styles/kendo.default.min.css">
    <link rel="stylesheet" href="http://cdn.kendostatic.com/2014.2.716/styles/kendo.dataviz.min.css">
    <link rel="stylesheet" href="http://cdn.kendostatic.com/2014.2.716/styles/kendo.dataviz.default.min.css">
    <link rel="stylesheet" href="http://cdn.kendostatic.com/2014.2.716/styles/kendo.mobile.all.min.css">

    <script src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
    <script src="http://cdn.kendostatic.com/2014.2.716/js/kendo.all.min.js"></script>
</head>
<body>
 
<div id="myform">
    <input name="username1" required /> <br />
    <input name="username2" required /> <br />
    <input name="username3" required /> <br />
  <button id="save">Save</button>
    <div id="errors"></div>
</div>

<script>
    // attach a validator to the container and get a reference
    var validatable = $("#myform").kendoValidator().data("kendoValidator");

    $("#save").click(function() {
      //validate the input elements and check if there are any errors
      if (validatable.validate() === false) {
        // get the errors and write them out to the "errors" html container
        var errors = validatable.errors();
        $(errors).each(function() {
          $("#errors").append("<strong style='color:red'>"+this+"</strong><br/>");
        });
      }
    });
</script>
</body>
</html>

No hay comentarios:

Publicar un comentario