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.


 Subscribe in a reader

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

Notices




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

SuperMember
Join Date: Oct 2007
Location: UK
Posts: 1,341
Blog Entries: 2
Thanks: 11
Thanked 49 Times in 46 Posts
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)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote

  #2  
Old Feb 28th, 2008, 16:11
Jack Franklin's Avatar
Moderator

SuperMember
Join Date: May 2007
Location: Cornwall, England
Posts: 1,408
Blog Entries: 8
Thanks: 18
Thanked 14 Times in 14 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??
__________________
Jack Franklin - Webforumz Moderator
(x)HTML | CSS | PHP | MySQL | JQuery (Javascript)
Contact: My Blog | Twitter | Delicious
Want Lessons? PM me.
If you think I've helped, please press the 'Thanks' Button.
Last Blog Entry: A Week with VBulletin (Aug 28th, 2008)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #3  
Old Feb 28th, 2008, 16:37
Aso's Avatar
Aso Aso is offline
Moderator

SuperMember
Join Date: Oct 2007
Location: UK
Posts: 1,341
Blog Entries: 2
Thanks: 11
Thanked 49 Times in 46 Posts
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)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #4  
Old Feb 28th, 2008, 16:47
Jack Franklin's Avatar
Moderator

SuperMember
Join Date: May 2007
Location: Cornwall, England
Posts: 1,408
Blog Entries: 8
Thanks: 18
Thanked 14 Times in 14 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.
__________________
Jack Franklin - Webforumz Moderator
(x)HTML | CSS | PHP | MySQL | JQuery (Javascript)
Contact: My Blog | Twitter | Delicious
Want Lessons? PM me.
If you think I've helped, please press the 'Thanks' Button.
Last Blog Entry: A Week with VBulletin (Aug 28th, 2008)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
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 03:34.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization 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