atrum Posted March 15, 2009 Share Posted March 15, 2009 Ok. so, I am still a little new at javascript, and I need to know how to create a function that does the following. if field == blank change.textbox.color= somecolor else move onto the next field and repeat the check on the next field. I know how to display an alert popup box if a field is blank. I just need the part that calls the field object. Can any one help me on this? Also, if what I asked doesn't make sense, please tell me and I can try and explain it differently. Thanks. Quote Link to comment Share on other sites More sharing options...
jackpf Posted March 15, 2009 Share Posted March 15, 2009 Hey, I thought your problem was quite intruiging so I had a go and came up with this: <html> <head> <script type="text/javascript"> function change() { var input = document.getElementById('input'); if(input.value == '') { input.style.background = 'red'; } else { input.style.background = ''; } } </script> </head> <body onload="change()"> <input id="input" type="text" onkeyup="change()" /> </body> </html> Now, considering I'm a bit of a javascript noob, I'm quite proud of this Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.