validate empty textboxes before leaving the textbo

2019-09-01 17:58发布

问题:

I am developing an asp web application and I have an online form, I can already prompt the users that the text box is empty after clicking the submit button, however I want to prompt the user that the textbox cannot be left blank..

for example last name, middle name, and first name, when I am on the last name field, and I went to the middle name field, the last name textbox was left empty, I want to prompt the users that the last name textbox was left empty, and when there is already value, the prompt will be removed,

also i want the textbox to be bordered red then resume to normal when there is value,, thanks for your answers

回答1:

If you are using MVC, then use data annotations or you can use any jquery validation library like http://www.position-relative.net/creation/formValidator/demos/demoValidators.html