How to check a single field using Hibernate Validator?

I am looking for a way to check one field at a time. This is so when the user fills out the form, every time a click or blur event occurs for each field, I can check this field separately and show / hide its error message.

Is it possible? If so, how can I do this? Some Google searches did not display any results that validate a single field, not the entire form.

+3
source share
2 answers

You can use javax.validation.Validator#validateProperty()for this purpose.

+3
source

Javascript Regular Expressions / . :

DOM, .

var letterField = document.getElementById('letterField'); // DOM element containing user input 
letterField.addEventListener('keyup', function() { // key press event listener using anonymous function
    if (event.keyCode === 13) { // run this code if the 'enter' key is pressed
        if ( ... ) { 
            ...
        };
    };
};

, . jQuery API :

userInputError.delay(800).fadeOut(); 
0

All Articles