-1

I am validating an HTML using knockout-validation, I need to focus the cursor on the first control having error how could I do that?

Please help..

Thanks

Animesh
  • 323
  • 3
  • 19
  • I've attempted to answer but it's a bit tricky to know what you may have tried already unsuccessfully if you don't add that info to the question. – Starscream1984 Apr 10 '14 at 11:56

1 Answers1

3

Make sure you are setting an error class for your elements in the data-bind attrbute of all elements being validated:

data-bind = " ...
              validationOptions: { errorElementClass: 'input-validation-error' }
              ... "

Then at the point of validation you can get all of these elements with jquery and just apply focus to the first one:

$(".input-validation-error").first().focus();
Starscream1984
  • 3,072
  • 1
  • 19
  • 27