This is a migrated thread and some comments may be shown as answers.

Require Field validation Check for Space bar input

1 Answer 1227 Views
Validation
This is a migrated thread and some comments may be shown as answers.
Chatra
Top achievements
Rank 1
Chatra asked on 23 Sep 2014, 02:36 PM
Hi,

I have a field set to required field validation.But had input given to that field is just  a "Spacebar".

And the field does not contain any value in it and able to submit the form with empty field.

How to prevent this... Yaa I can go and use the java script to loop through required fields but then what is use of the required field.

Thanks
Chatrapathi Chennam

1 Answer, 1 is accepted

Sort by
0
Rosen
Telerik team
answered on 24 Sep 2014, 09:20 AM
Hello Chatra,

The Kendo UI Validator required validation rule tries to mimic the built-in browsers validation behavior - which you can check in this sample test page. However, you may override the built-in required rule and implement it as to fit in your scenario. For example:

<form>
  <input name="input" required/>
  <button>Click me</button>
</form>
<script>
  $("form").kendoValidator({
    rules: {
      required: function(input) {
        if (input.filter("[required]").length && $.trim(input.val()) == "") {
          return false;
        }
        return true;
      }
    }
  });
</script>


Regards,
Rosen
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
Tags
Validation
Asked by
Chatra
Top achievements
Rank 1
Answers by
Rosen
Telerik team
Share this question
or