HTML, JavaScript And CSS Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsProgrammingHTML, JavaScript And CSS Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
  #1  
Old October 16th, 2004, 04:44 PM
DuA11 DuA11 is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Oct 2004
Posts: 4 DuA11 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 15 m 30 sec
Reputation Power: 0
Need Simple Help

I WANT MY TEXTBOX TO ACCEPT ONLY NUMBERS.
This script works fine, but.. what to do if I want to check more textbox ???
The input name of the textbox is <input name="str"
I want to "add str+agi+vit+nrg" textboxes

Here is my script: (please edit it)
Quote:
<script language="JavaScript1.2">
function duallcheck(){
var x=document.form1.str.value

var anum=/(^\d+$)|(^\d+\.\d+$)/
if (anum.test(x))
testresult=true
else{
alert("Do not use -")
testresult=false
}
return (testresult)
}

</script>

<script>
function checking(){
if (document.layers||document.all||document.getElemen tById)
return duallcheck()
else
return true
}
</script>

Reply With Quote
  #2  
Old October 16th, 2004, 05:43 PM
Phoenix's Avatar
Phoenix Phoenix is offline
Web-Standards Evangelist
ASP Free Intermediate (1500 - 1999 posts)
 
Join Date: Nov 2003
Posts: 1,522 Phoenix User rank is Corporal (100 - 500 Reputation Level)Phoenix User rank is Corporal (100 - 500 Reputation Level)Phoenix User rank is Corporal (100 - 500 Reputation Level)Phoenix User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 4 Days 23 h 48 m 4 sec
Reputation Power: 8
Quote:
Originally Posted by DuA11
I WANT MY TEXTBOX TO ACCEPT ONLY NUMBERS


See here

First off... the "name" attribute for form input elements isn't for selection, rather its so that server-side scripts can identify incoming information (in a nutshell)

To uniquely identify elements, you're supposed to use the "id" attribute

Your script is also missing a lot of EOL characters

That aside, I have no idea what it is you want the script to do

Any chance you can articulate yourself in a more coherent manner?

Reply With Quote
  #3  
Old October 16th, 2004, 11:29 PM
Lafinboy's Avatar
Lafinboy Lafinboy is offline
The Laughing Moderator
ASP Free Loyal (3000 - 3499 posts)
 
Join Date: Apr 2004
Location: Sydney, Australia
Posts: 3,267 Lafinboy User rank is Sergeant (500 - 2000 Reputation Level)Lafinboy User rank is Sergeant (500 - 2000 Reputation Level)Lafinboy User rank is Sergeant (500 - 2000 Reputation Level)Lafinboy User rank is Sergeant (500 - 2000 Reputation Level)Lafinboy User rank is Sergeant (500 - 2000 Reputation Level)  Folding Points: 29199 Folding Title: Starter FolderFolding Points: 29199 Folding Title: Starter Folder
Time spent in forums: 2 Weeks 1 Day 10 h 48 m 12 sec
Reputation Power: 15
Send a message via ICQ to Lafinboy Send a message via AIM to Lafinboy Send a message via MSN to Lafinboy Send a message via Yahoo to Lafinboy Send a message via Skype to Lafinboy
Quote:
Here is my script

If this is your script then I would assume you know what it does and therefore how to change it to do what you want.

If you have copied the script with no understanding of what it does I suggest you do some research into javascript validation functions, or as this is an ASP forum maybe look into VBScript IsNumeric functions.

Reply With Quote
  #4  
Old October 17th, 2004, 06:18 AM
Phoenix's Avatar
Phoenix Phoenix is offline
Web-Standards Evangelist
ASP Free Intermediate (1500 - 1999 posts)
 
Join Date: Nov 2003
Posts: 1,522 Phoenix User rank is Corporal (100 - 500 Reputation Level)Phoenix User rank is Corporal (100 - 500 Reputation Level)Phoenix User rank is Corporal (100 - 500 Reputation Level)Phoenix User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 4 Days 23 h 48 m 4 sec
Reputation Power: 8
Quote:
Originally Posted by Lafinboy
as this is an ASP forum maybe look into VBScript IsNumeric functions.


And leave 25% of non-VBS enabled browsers out in the cold

Reply With Quote
  #5  
Old October 17th, 2004, 06:38 AM
Lafinboy's Avatar
Lafinboy Lafinboy is offline
The Laughing Moderator
ASP Free Loyal (3000 - 3499 posts)
 
Join Date: Apr 2004
Location: Sydney, Australia
Posts: 3,267 Lafinboy User rank is Sergeant (500 - 2000 Reputation Level)Lafinboy User rank is Sergeant (500 - 2000 Reputation Level)Lafinboy User rank is Sergeant (500 - 2000 Reputation Level)Lafinboy User rank is Sergeant (500 - 2000 Reputation Level)Lafinboy User rank is Sergeant (500 - 2000 Reputation Level)  Folding Points: 29199 Folding Title: Starter FolderFolding Points: 29199 Folding Title: Starter Folder
Time spent in forums: 2 Weeks 1 Day 10 h 48 m 12 sec
Reputation Power: 15
Send a message via ICQ to Lafinboy Send a message via AIM to Lafinboy Send a message via MSN to Lafinboy Send a message via Yahoo to Lafinboy Send a message via Skype to Lafinboy
mmmmm ..... picky

Reply With Quote
  #6  
Old October 17th, 2004, 08:21 AM
DuA11 DuA11 is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Oct 2004
Posts: 4 DuA11 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 15 m 30 sec
Reputation Power: 0
Please Help Me with This Simple Question

I'm green at javascripts...

Help me to make more numeric textboxes...

My script checks only 1 "str" textbox..

How to add more ???

Reply With Quote
  #7  
Old October 17th, 2004, 09:19 AM
Shadow Wizard's Avatar
Shadow Wizard Shadow Wizard is offline
Moderator From Beyond
ASP Free God 45th Plane (27000 - 27499 posts)
 
Join Date: Sep 2004
Location: Israel
Posts: 27,291 Shadow Wizard User rank is General 12nd Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 12nd Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 12nd Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 12nd Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 12nd Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 12nd Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 12nd Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 12nd Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 12nd Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 12nd Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 12nd Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 12nd Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 12nd Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 12nd Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 12nd Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 12nd Grade (Above 100000 Reputation Level)  Folding Points: 359459 Folding Title: Super Ultimate Folder - Level 1Folding Points: 359459 Folding Title: Super Ultimate Folder - Level 1Folding Points: 359459 Folding Title: Super Ultimate Folder - Level 1Folding Points: 359459 Folding Title: Super Ultimate Folder - Level 1Folding Points: 359459 Folding Title: Super Ultimate Folder - Level 1Folding Points: 359459 Folding Title: Super Ultimate Folder - Level 1
Time spent in forums: 3 Months 1 Week 6 Days 14 h 16 m 8 sec
Reputation Power: 1802
add more html:
<input type=text>
to add more text boxes on the screen.

Reply With Quote
  #8  
Old October 17th, 2004, 11:19 AM
Phoenix's Avatar
Phoenix Phoenix is offline
Web-Standards Evangelist
ASP Free Intermediate (1500 - 1999 posts)
 
Join Date: Nov 2003
Posts: 1,522 Phoenix User rank is Corporal (100 - 500 Reputation Level)Phoenix User rank is Corporal (100 - 500 Reputation Level)Phoenix User rank is Corporal (100 - 500 Reputation Level)Phoenix User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 4 Days 23 h 48 m 4 sec
Reputation Power: 8
Quote:
Originally Posted by Shadow Wizard
add more html:
<input type=text>
to add more text boxes on the screen.


Correction

<input type="text" id="textinput2" name="textinput2" />

There

Reply With Quote
  #9  
Old October 17th, 2004, 11:21 AM
Shadow Wizard's Avatar
Shadow Wizard Shadow Wizard is offline
Moderator From Beyond
ASP Free God 45th Plane (27000 - 27499 posts)
 
Join Date: Sep 2004
Location: Israel
Posts: 27,291 Shadow Wizard User rank is General 12nd Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 12nd Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 12nd Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 12nd Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 12nd Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 12nd Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 12nd Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 12nd Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 12nd Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 12nd Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 12nd Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 12nd Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 12nd Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 12nd Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 12nd Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 12nd Grade (Above 100000 Reputation Level)  Folding Points: 359459 Folding Title: Super Ultimate Folder - Level 1Folding Points: 359459 Folding Title: Super Ultimate Folder - Level 1Folding Points: 359459 Folding Title: Super Ultimate Folder - Level 1Folding Points: 359459 Folding Title: Super Ultimate Folder - Level 1Folding Points: 359459 Folding Title: Super Ultimate Folder - Level 1Folding Points: 359459 Folding Title: Super Ultimate Folder - Level 1
Time spent in forums: 3 Months 1 Week 6 Days 14 h 16 m 8 sec
Reputation Power: 1802
hmm...
I wonder what will happen if he adds this:
<input type crash>

j/k

Reply With Quote
  #10  
Old October 17th, 2004, 12:17 PM
Phoenix's Avatar
Phoenix Phoenix is offline
Web-Standards Evangelist
ASP Free Intermediate (1500 - 1999 posts)
 
Join Date: Nov 2003
Posts: 1,522 Phoenix User rank is Corporal (100 - 500 Reputation Level)Phoenix User rank is Corporal (100 - 500 Reputation Level)Phoenix User rank is Corporal (100 - 500 Reputation Level)Phoenix User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 4 Days 23 h 48 m 4 sec
Reputation Power: 8
neither type nor crash are flag attributes (all of which are depreciated anyway)

So nothing would happen.... because the required attribute "type" wasn't specified properly, you would get either a blank text input box, a hidden field, or a non-rendered element depending upon which agent is rendering the markup.

Of course, if you want to crash a browser.... specifically, an M$IE browser, use the following code

Code:
<script language="VBScript">
Dim i
i = 0
Do While i < 1
    Document.Write("haha")
Loop
</script>


Enjoy

Reply With Quote
  #11  
Old October 18th, 2004, 01:15 AM
Shadow Wizard's Avatar
Shadow Wizard Shadow Wizard is offline
Moderator From Beyond
ASP Free God 45th Plane (27000 - 27499 posts)
 
Join Date: Sep 2004
Location: Israel
Posts: 27,291 Shadow Wizard User rank is General 12nd Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 12nd Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 12nd Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 12nd Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 12nd Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 12nd Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 12nd Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 12nd Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 12nd Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 12nd Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 12nd Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 12nd Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 12nd Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 12nd Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 12nd Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 12nd Grade (Above 100000 Reputation Level)  Folding Points: 359459 Folding Title: Super Ultimate Folder - Level 1Folding Points: 359459 Folding Title: Super Ultimate Folder - Level 1Folding Points: 359459 Folding Title: Super Ultimate Folder - Level 1Folding Points: 359459 Folding Title: Super Ultimate Folder - Level 1Folding Points: 359459 Folding Title: Super Ultimate Folder - Level 1Folding Points: 359459 Folding Title: Super Ultimate Folder - Level 1
Time spent in forums: 3 Months 1 Week 6 Days 14 h 16 m 8 sec
Reputation Power: 1802
lol
the <input type crash> is actually crashing IE6, at least in my Windows2000 machine over here. moreover, my Norton Antivirus detected the html file with this line (which I wrote!) as virus!! (Trojan.CrashIE virus)
LMAO!

Reply With Quote
  #12  
Old October 18th, 2004, 10:58 AM
Phoenix's Avatar
Phoenix Phoenix is offline
Web-Standards Evangelist
ASP Free Intermediate (1500 - 1999 posts)
 
Join Date: Nov 2003
Posts: 1,522 Phoenix User rank is Corporal (100 - 500 Reputation Level)Phoenix User rank is Corporal (100 - 500 Reputation Level)Phoenix User rank is Corporal (100 - 500 Reputation Level)Phoenix User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 4 Days 23 h 48 m 4 sec
Reputation Power: 8
Google for it

You'll see its just a bug in IE, probably written in deliberatly by some disaffected or disgruntled employee

Reply With Quote
  #13  
Old October 18th, 2004, 11:18 AM
Shadow Wizard's Avatar
Shadow Wizard Shadow Wizard is offline
Moderator From Beyond
ASP Free God 45th Plane (27000 - 27499 posts)
 
Join Date: Sep 2004
Location: Israel
Posts: 27,291 Shadow Wizard User rank is General 12nd Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 12nd Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 12nd Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 12nd Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 12nd Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 12nd Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 12nd Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 12nd Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 12nd Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 12nd Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 12nd Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 12nd Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 12nd Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 12nd Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 12nd Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 12nd Grade (Above 100000 Reputation Level)  Folding Points: 359459 Folding Title: Super Ultimate Folder - Level 1Folding Points: 359459 Folding Title: Super Ultimate Folder - Level 1Folding Points: 359459 Folding Title: Super Ultimate Folder - Level 1Folding Points: 359459 Folding Title: Super Ultimate Folder - Level 1Folding Points: 359459 Folding Title: Super Ultimate Folder - Level 1Folding Points: 359459 Folding Title: Super Ultimate Folder - Level 1
Time spent in forums: 3 Months 1 Week 6 Days 14 h 16 m 8 sec
Reputation Power: 1802
bug or no bug, it caused my browser to crash.
and it's identified as virus.
reason who caused it or why is irrelevant...