jQuery - How do I make sure a user enters text before performing any other operations? -


i'm allowing users create folders in app. once user clicks on "new folder" icon, display folder text box user enter name of folder.

how make sure user enters name before clicking on "new folder" icon again or matter before using application else?

i tried input change event, offcourse, fires when user attempts enter name.

$(".new-folder-name").change(function () {       var newfoldername = $(".new-folder-name").val();     if (newfoldername == "") {         alert("please enter name new folder.");     } else {         alert("good, entered name: " + newfoldername);     } }); 

but if user leaves text box blank , goes on doing other things app?

how can force user enter text first before doing else?

force user input
after:

alert("please enter name new folder."); 

add:

settimeout(function() {$(".new-folder-name").focus();},10); 

forces focus on textbox.

also, change .change() .blur()

modal popup
there several options out there. put textbox in modal popup , don't let them close until enter valid.


Comments

Popular posts from this blog

java - Run a .jar on Heroku -

java - Jtable duplicate Rows -

validation - How to pass paramaters like unix into windows batch file -