ASP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsProgrammingASP Development

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 July 1st, 2009, 05:09 AM
foreverforever foreverforever is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Apr 2008
Posts: 184 foreverforever User rank is Major (30000 - 40000 Reputation Level)foreverforever User rank is Major (30000 - 40000 Reputation Level)foreverforever User rank is Major (30000 - 40000 Reputation Level)foreverforever User rank is Major (30000 - 40000 Reputation Level)foreverforever User rank is Major (30000 - 40000 Reputation Level)foreverforever User rank is Major (30000 - 40000 Reputation Level)foreverforever User rank is Major (30000 - 40000 Reputation Level)foreverforever User rank is Major (30000 - 40000 Reputation Level)foreverforever User rank is Major (30000 - 40000 Reputation Level)foreverforever User rank is Major (30000 - 40000 Reputation Level) 
Time spent in forums: 4 Days 5 h 33 m 7 sec
Reputation Power: 335
Text Area - submit form when user strikes Enter button

Hi,

I have a form with a text area. If a user strikes the Enter button on their keyboard, this effects a carriage return within the text area. Rather than effecting a carriage return within the text area, I want the form to submit. Can someone please tell me whether this is possible and (if so) how it can be achieved?

Just in case it's relevant, I will mention that I'm using a function to check that all the characters entered into the text area are permitted. I'm permitting A-Z, 0-9, comma, full-stop/period, space, and underscore. This works fine. Here's the code:
Code:
<%
Function IsAlphaNumericPlusCFS_(sString)
'0-9 , A-Z , comma , full-stop, space, underscore
  Dim nChar, i
  IsAlphaNumericPlusCFS_ = True
  For i = 1 To Len(sString)
    nChar = Asc(LCase(Mid(sString, i, 1)))
    If not ((nChar = 32 or nChar = 44 or nChar = 46) or (nChar > 47 And nChar < 58) or (nChar = 95) or (nChar > 96 And nChar < 123)) Then
      IsAlphaNumericPlusCFS_ = False
      Exit For
    End If
  Next
End Function 
%>

If it can be achieved, I'll add nChar=13 to the list of permitted characters.

Thanks.

Reply With Quote
  #2  
Old July 1st, 2009, 10:58 AM
sync_or_swim's Avatar
sync_or_swim sync_or_swim is offline
Moderator
Click here for more information.
 
Join Date: Mar 2006
Location: South Wales
Posts: 3,416 sync_or_swim User rank is General 12nd Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 12nd Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 12nd Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 12nd Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 12nd Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 12nd Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 12nd Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 12nd Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 12nd Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 12nd Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 12nd Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 12nd Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 12nd Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 12nd Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 12nd Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 12nd Grade (Above 100000 Reputation Level) 
Time spent in forums: 2 Months 23 h 57 m 27 sec
Reputation Power: 1800
Hi,

It is possible to use javascript to trap the keypress and act on Char(13) if the user hits enter. The issue you will have though is that javascript can be disabled in the client's browser, rendering your code useless.
Code:
<html>
<head>
<script>
function handleKeyPress(e)
{
	if (!e) e = window.event;
	if (e && e.keyCode == 13)
	{
	document.myForm.submit();
	}
}
</script>
</head>
<body>
<form name="myForm" method="post" action="test.asp">
<textarea name="myTextArea" onkeypress="return handleKeyPress(event);"></textarea>
</form>
</body>
</html>

Reply With Quote
  #3  
Old July 1st, 2009, 12:44 PM
foreverforever foreverforever is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Apr 2008
Posts: 184 foreverforever User rank is Major (30000 - 40000 Reputation Level)foreverforever User rank is Major (30000 - 40000 Reputation Level)foreverforever User rank is Major (30000 - 40000 Reputation Level)foreverforever User rank is Major (30000 - 40000 Reputation Level)foreverforever User rank is Major (30000 - 40000 Reputation Level)foreverforever User rank is Major (30000 - 40000 Reputation Level)foreverforever User rank is Major (30000 - 40000 Reputation Level)foreverforever User rank is Major (30000 - 40000 Reputation Level)foreverforever User rank is Major (30000 - 40000 Reputation Level)foreverforever User rank is Major (30000 - 40000 Reputation Level) 
Time spent in forums: 4 Days 5 h 33 m 7 sec
Reputation Power: 335
Hi SOS,

Thanks for the code and the advice.
Quote:
Originally Posted by sync_or_swim
The issue you will have though is that javascript can be disabled in the client's browser, rendering your code useless.
Sounds like I'm going to be best served by tackling it from another angle and replacing the Enter character (13) with a Space character (32) when the form is submitted.

All users will be warned that only the previously mentioned characters are permitted so I don't think that I need to warn them about Enter being ignored.

Could you possibly tell me if there is any practical reason why I shouldn't use replace?

Thanks again,

ff

Reply With Quote
  #4  
Old July 2nd, 2009, 03:25 AM
sync_or_swim's Avatar
sync_or_swim sync_or_swim is offline
Moderator
Click here for more information.
 
Join Date: Mar 2006
Location: South Wales
Posts: 3,416 sync_or_swim User rank is General 12nd Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 12nd Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 12nd Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 12nd Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 12nd Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 12nd Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 12nd Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 12nd Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 12nd Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 12nd Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 12nd Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 12nd Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 12nd Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 12nd Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 12nd Grade (Above 100000 Reputation Level)sync_or_swim User rank is General 12nd Grade (Above 100000 Reputation Level) 
Time spent in forums: 2 Months 23 h 57 m 27 sec
Reputation Power: 1800
Quote:
Originally Posted by foreverforever
Could you possibly tell me if there is any practical reason why I shouldn't use replace?

Thanks again,

ff

No, I cant think of any reason why you shouldnt use replace.

I would always advise against relying upon a javascript to submit your form if you couldnt guarantee that all of the users have javascript enabled. At least using the replace method the form will behave the same for all users.
Comments on this post
foreverforever agrees!

Reply With Quote
  #5  
Old July 2nd, 2009, 11:16 AM
foreverforever foreverforever is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Apr 2008
Posts: 184 foreverforever User rank is Major (30000 - 40000 Reputation Level)foreverforever User rank is Major (30000 - 40000 Reputation Level)foreverforever User rank is Major (30000 - 40000 Reputation Level)foreverforever User rank is Major (30000 - 40000 Reputation Level)foreverforever User rank is Major (30000 - 40000 Reputation Level)foreverforever User rank is Major (30000 - 40000 Reputation Level)foreverforever User rank is Major (30000 - 40000 Reputation Level)foreverforever User rank is Major (30000 - 40000 Reputation Level)foreverforever User rank is Major (30000 - 40000 Reputation Level)foreverforever User rank is Major (30000 - 40000 Reputation Level) 
Time spent in forums: 4 Days 5 h 33 m 7 sec
Reputation Power: 335
That's good news, then. Thanks again, SOS.

ff

Reply With Quote
Reply

Viewing: ASP Free ForumsProgrammingASP Development > Text Area - submit form when user strikes Enter button


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.

 
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.

 
Power and Cooling Capacity Management for Data Centers
This paper describes the principles for achieving power and cooling capacity management.

 
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.

 
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.

 

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





© 2003-2009 by Developer Shed. All rights reserved. DS Cluster 5 Hosted by Hostway
Stay green...Green IT