Sunday, May 19, 2024
 Popular · Latest · Hot · Upcoming
23
rated 0 times [  30] [ 7]  / answers: 1 / hits: 96741  / 8 Years ago, fri, august 5, 2016, 12:00:00

On a contact form, I have several input fields. One of those fields, is an email address field:



<input type='text' name='input_email' onChange={this.validateEmail}/>


Right now, I have the email validation function set to the onChange attribute. Thus, while the user is entering characters into the email field, an error message appears the whole time.



I want to change this, so that this.validateEmail only gets called once when the user leaves that specific input field. How would I accomplish this?



I can't find any default object events that would solve this issue.



FYI, using ReactJS


More From » html

 Answers
12

You can use onblur() or onfocusout(). It will call function once you click out of that text field.



Example:





function myFunction() {
var x = document.getElementById(sometext);
x.value = x.value.toUpperCase();
}

<input type=text id=sometext onfocusout=myFunction()>




[#61133] Wednesday, August 3, 2016, 8 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
mckinleykeyshawnb

Total Points: 281
Total Questions: 99
Total Answers: 111

Location: Saudi Arabia
Member since Sat, Aug 20, 2022
2 Years ago
;