1

How do we achieve validationgroup functionality present in asp.net using only HTML5? I am using this library: http://afarkas.github.com/webshim/demos/demos/webforms/4-webforms-custom-validity.html

Basically I have a textbox and button and I want this textbox and this button to into one group and the rest can be in different group. So this button should only validate for the single textbox and not the entire form.

4
  • some moron downvoted my valid question :) Commented Nov 2, 2012 at 12:16
  • Jack, I'm not the one who downvoted you, but we don't call people morons over here. Learn some manners. On the topic of your question, what have you tried? The lack of obvious effort is probably the reason of your previous downvote. Commented Nov 2, 2012 at 13:20
  • @MarioDeSchaepmeester: What could I have tried before I know anything about it? If you happen to read the question you will come to know that I've provided the link to the library which I am using and have tried it's API. Commented Nov 4, 2012 at 4:05
  • @MarioDeSchaepmeester: By the way I've seen moron keyword many times on SO. As a matter of fact, even these users have their names as morons: stackoverflow.com/users/870481/moron stackoverflow.com/users/22987/the-happy-moron stackoverflow.com/users/1203815/fighting-it-morons stackoverflow.com/questions/184618/… Do you need more links? Commented Nov 4, 2012 at 4:06

1 Answer 1

2

You can call checkValidity() on the individual form elements and then take whatever action you deem appropriate. Here is a simple example:

<div id="d1">
    <input type="text" required id="i1">
    <button onclick="if (document.getElementById('i1').checkValidity())
        {document.getElementById('d1').className = 'va'} 
      else 
        {document.getElementById('d1').className = 'in'}; return false;">Check 1</button>
</div>

Obviously in real life you wouldn't use a hacky inline event handler but the principle would be the same.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.