Web Hosting Deals Holiday Logo Design Webcam Chat Website Header Templates Register domain Search Engine Optimisation Web Hosting
Go Back   Talk Mania Forum > Tutorials > PHP / Perl / Java / JavaScript / CGI Tutorials

PHP / Perl / Java / JavaScript / CGI Tutorials PHP / Perl / Java / JavaScript / CGI Tutorials Please do not use this Forum to advertise your site or to link to tutorials.

 Image
Buy Sell Downloads

Reply
 
Submit Tools LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 05-29-2007, 11:15 PM
Senior Member
 
Join Date: May 2007
Posts: 181
Blog Entries: 1
skyfe is on a distinguished road
Text box, enble/disable submit button

Hello, I made a simple script which will clear the text boxes when you click on it so you can type in it and also will disable the submit button, untill those fiellds are filled in. The script could be a lot shorter but "OR" didn't work in my script, and I'm kinda new to javascript caus I kinda started learning it about... yesterday xD anyways xD here it is:

Quote:
<html>
<head>
<script language="javascript">
function check() {
if(document.login.user.value != "username") {
if(document.login.user.value != "") {
if(document.login.pass.value != "" ) {
if(document.login.pass.value != "password") {
document.login.submit.disabled = "";
}
}
}
}
if(document.login.user.value == "" ) {
document.login.submit.disabled = "enabled";
}
if(document.login.user.value == "username") {
document.login.submit.disabled = "enabled";
}
if(document.login.pass.value == "password") {
document.login.submit.disabled = "enabled";
}
if(document.login.pass.value == "") {
document.login.submit.disabled = "enabled";
}
}
</script>
</head>
<body>
<form name="login" OnClick="check();">
<input type="text" name="user" value="username" OnClick="check(); if(this.value == 'username') { this.value = '' }" OnChange="check();" OnBlur="check();" onkeyup="check();">
<input type="password" name="pass" value="password" OnClick="check(); if(this.value == 'password') { this.value = '' } " OnChange="check();" OnBlur="check();" onkeyup="check();">
<input type="submit" value="login" name="submit" disabled="check();" OnClick="check();" OnBlur="check();" OnChange="check();">
</form>
</body>
</html>
Don't have the time at the moment to explain the things, will edit the post later have fun with it
and btw, if you want to let it return the value of the fields to 'username' and 'password' once the user clicks somewhere else then in one of the fields, then you can also combine it with the clearing form script from FTH8er
Greetz ^^


Last edited by skyfe; 05-29-2007 at 11:18 PM.
Reply With Quote
  #2 (permalink)  
Old 09-29-2008, 11:20 AM
Member
 
Join Date: Sep 2008
Posts: 33
grafimir is on a distinguished road
thanx for nice tutorial
Reply With Quote
  #3 (permalink)  
Old 10-22-2008, 10:00 PM
Junior Member
 
Join Date: Aug 2008
Posts: 25
brumaluco is on a distinguished road
Very Good Tutorial
Reply With Quote
  #4 (permalink)  
Old 11-30-2008, 12:46 PM
Junior Member
 
Join Date: Nov 2008
Posts: 26
ash74 is on a distinguished road
thank for great sharing

Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

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
Forum Jump


All times are GMT +2. The time now is 01:59 AM.


Fake ID

Powered by vBulletin® Version 3.7.1
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0 RC8
Forums Copyright © Talk-Mania.com