Update isValid function

Now, isValid checks if the element is a input/select/textarea, and validate the element.