Add class if input not empty on-the-fly

This is a discussion on "Add class if input not empty on-the-fly" within the JavaScript Forum section. This forum, and the thread "Add class if input not empty on-the-fly are both part of the Program Your Website category.



Go Back   Webforumz.com > Main Forums > Program Your Website > JavaScript Forum

Notices


Reply
 
LinkBack Thread Tools
  #1 (permalink)  
Old Feb 28th, 2008, 15:52
Aso's Avatar
Aso Aso is offline
Chief Moderator

SuperMember
Join Date: Oct 2007
Location: UK
Posts: 1,011
Blog Entries: 2
Thanks: 5
Thanked 23 Times in 20 Posts
Send a message via Skype™ to Aso
Question Add class if input not empty on-the-fly

How could I check if any input in a form is no longer empty, and if so give it a class 'ent', in real time.

And if a user went back and deleted the contents of the input, the class would be removed.

Many thanks

Alex
Last Blog Entry: The Google Misconception (Feb 3rd, 2008)
Reply With Quote

  #2 (permalink)  
Old Feb 28th, 2008, 16:11
Jack Franklin's Avatar
Resources Administrator

SuperMember
Join Date: May 2007
Location: Cornwall, England
Posts: 1,268
Blog Entries: 7
Thanks: 10
Thanked 4 Times in 4 Posts
Re: Add class if input not empty on-the-fly

Well, i'm stating the obvious but javascript is done when the page loads right? But AJAX is done without needing Refreshing, so maybe that might be the key??
Last Blog Entry: My Latest Project - Grilling Gurus... (Jun 11th, 2008)
Reply With Quote
  #3 (permalink)  
Old Feb 28th, 2008, 16:37
Aso's Avatar
Aso Aso is offline
Chief Moderator

SuperMember
Join Date: Oct 2007
Location: UK
Posts: 1,011
Blog Entries: 2
Thanks: 5
Thanked 23 Times in 20 Posts
Send a message via Skype™ to Aso
Re: Add class if input not empty on-the-fly

I'm not sure if I'd need AJAX - I don't need to communicate with the server here.

It's hard to explain because I'm not sure how it works anyway

How about this?
Code: Select all
onMouseOut {
    
    //Check if input is empty
    
    if empty {
         // add class 'ent'
    }
    if not empty {
        // remove class (if it exists)
    }
}
(I know that's non-existent code, but it helps me explain )
Last Blog Entry: The Google Misconception (Feb 3rd, 2008)
Reply With Quote
  #4 (permalink)  
Old Feb 28th, 2008, 16:47
Jack Franklin's Avatar
Resources Administrator

SuperMember
Join Date: May 2007
Location: Cornwall, England
Posts: 1,268
Blog Entries: 7
Thanks: 10
Thanked 4 Times in 4 Posts
Re: Add class if input not empty on-the-fly

THat could work. I've only just started working with Javascript, so I'm no expert.
Last Blog Entry: My Latest Project - Grilling Gurus... (Jun 11th, 2008)
Reply With Quote
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
isset and empty karinne PHP Forum 15 Jan 28th, 2008 12:37
[SOLVED] div class and div id danny322 Web Page Design 1 Nov 22nd, 2007 12:52
FLASH - validating input fields if empty before clicking submit button kyutkb Flash & Multimedia Forum 3 Jul 24th, 2007 15:38
array of class janper Flash & Multimedia Forum 4 Apr 9th, 2007 13:54
asp script to show element if 2 recordset are both empty? therese Classic ASP 4 Dec 1st, 2005 10:24


All times are GMT. The time now is 10:42.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC8
© 2003-2008 Webforumz.com : All Rights Reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43