• Post Reply Bookmark Topic Watch Topic
  • New Topic

enable/disable Save button for multiple fields in a from

 
praneeth ram
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

I want to enable/disable save button after 8 fields validation in my page.
I have old technique:- that is keep a boolean flag for every field(in our case 8 flags), update corresponding field(when the fileld is valid/invalid) and check, if all the flags are true then only "enable/disable" save button.

My question is do we have any better approach, like using one variable.


I am very thankful for any suggestions/solutions.

Thanks,
Praneeth
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65678
129
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You don't need any variables at all. Have a change handler on the form that checks to see if the validation requirements are met, and change the state of the button if so.
 
Gravity is a harsh mistress. But this tiny ad is pretty easy to deal with:
the new thread boost feature: great for the advertiser and smooth for the coderanch user
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!