Client Side Things
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Codewalkers ForumsOther TechnologiesClient Side Things

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 Codewalkers Forums Sponsor:
  #1  
Old February 18th, 2003, 02:03 PM
stardust77 stardust77 is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 24 stardust77 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Javascript problem

I probably shouldn't be posting it in here, but it's just a simple error-checking javascript that I just couldn't get right. =(

Am hoping someone here can help!

Here's my JS function :
php Code:
Original - php Code
  1.  
  2. function Check(form) {
  3.  
  4. // check for empty textboxes
  5. if (form.Name.value == "")   {
  6.     alert("Please fill in your name.");
  7.         form.Name.select();
  8.     }
  9. if (form.Surname.value == "")   {
  10.         alert("Please fill in your surname.");
  11.         form.Surname.select();
  12.     }
  13. if (form.Address.value == "")   {
  14.         alert("Please fill in your address.");
  15.         //form.Address.focus();
  16.     }
  17. .
  18. .
  19. .


and here's the form itself...
php Code:
Original - php Code
  1.  
  2. <form name="ChangeDetails" onSubmit="Check(ChangeDetails); return false;">
  3.   Please change your details in the respective boxes below.
  4.   <p>
  5.   <table width="400" border="1">
  6. <?
  7.     // get array variables into form for users to update
  8.     foreach ($detailsarray as $changed) {
  9.         echo "<tr>";
  10.         echo "<td><div align="right">".$changed." :&nbsp;</div></td>";
  11.         if ($changed=="Postal Code")  {
  12.             $changed="Postal_Code";
  13.             echo "<td width="200">
  14.             <input name=".$changed." type="text" size="40" maxlength="6"
  15.             onKeypress="if (event.keyCode < 45 || event.keyCode > 57) event.returnValue = false;">";
  16.         echo "</tr>";
  17.         }
  18.         else if ($changed=="Contact No")  {
  19.             $changed="Contact";
  20.             echo "<td width="200">
  21.             <input name=".$changed." type="text" size="40" maxlength="20"
  22.             onKeypress="if (event.keyCode < 45 || event.keyCode > 57) event.returnValue = false;">";
  23.         echo "</tr>";
  24.         }
  25.         else if ($changed=="E-Mail")  {
  26.             $changed="EMail";
  27.             echo "<td width="200">
  28.             <input name=".$changed." type="text" size="40" maxlength="255"
  29.             onKeypress="if (event.keyCode < 46 || (event.keyCode > 57 && event.keyCode < 64) || (event.keyCode > 90 && event.keyCode < 97) || event.keyCode > 122 || (event.keyCode > 46 && event.keyCode < 48)) event.returnValue = false;">";
  30.         echo "</tr>";
  31.         }
  32.         else    {
  33.             echo "<td width="200">
  34.             <input name=".$changed." type="text" size="40" maxlength="255">";
  35.         echo "</tr>";
  36.         }
  37.     }
  38. ?>


Whenever I check for just empty textboxes, it always posts back to itself. Without alert boxes sometimes even. Can anyone see what the problem is? I've been trying, but for the life of me, still can't see the problem.

Think I'm getting blind...

[edit: moved by notepad]

Reply With Quote
  #2  
Old February 21st, 2003, 01:56 AM
s0ccarstud s0ccarstud is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: Chicago, IL
Posts: 55 s0ccarstud User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 3
Send a message via Yahoo to s0ccarstud
RE: Javascript problem

you need to return false in your function.

Reply With Quote
Reply

Viewing: Codewalkers ForumsOther TechnologiesClient Side Things > Javascript problem


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump




 Free IT White Papers!
 
How to Present Effectively Online
This white paper offers practical and actionable advice on the key steps that any presenter should consider as they plan and execute a Webinar or online meeting.

Request Your Free Technology Downloads!
 
Open Source Security Myths
Open Source Software (OSS) is computer software whose source code is available to the general public with relaxed or non-existent intellectual property restrictions (or arrangement such as the public domain), and is usually developed with the input of many contributors.

Request Your Free Technology Downloads!
 
Power and Cooling Capacity Management for Data Centers
This paper describes the principles for achieving power and cooling capacity management.

Request Your Free Technology Downloads!
 
Scalable, Fault-Tolerant NAS for Oracle - The Next Generation
For several years NAS has been evolving as a storage alternative for Oracle databases, and for good reason: NAS is quite often the simplest, most cost-effective storage approach for Oracle. Learn about the benefits that HP's approach to scalable NAS brings to Oracle environments in this comprehensive white paper.

Request Your Free Technology Downloads!
 
Understanding Web Application Security Challenges
This white paper discusses many common threats and preventive measures for Web application security, and explains what you can do to help protect your organization.

Request Your Free Technology Downloads!
 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 




© 2003-2009 by Developer Shed. All rights reserved. DS Cluster 5 Hosted by Hostway
For more Enterprise Application Development news, visit eWeek