Let's face it. As long as people manually enter data, there are bound to be typos in your data. One common error is when a user adds extra spaces at the beginning or end of a form field. So how do you stop this?
First, you create a form.asp page and copy the code below:
Then, you use the TRIM function in your confirm.asp page to remove any spaces:
<% DIM strEmail, strFirstName, strLastName, strSubject, strComments strEmail = TRIM(Request.Form("Email")) strFirstName = TRIM(Request.Form("FirstName")) strLastName = TRIM(Request.Form("LastName")) strSubject = TRIM(Request.Form("Subject")) strComments = TRIM(Request.Form("Comments")) %>
The TRIM() function will remove any extra spaces from the beginning and end of each form field here, which insures better consistency within your database. If you are only concerned with removing spaces from the left or right side of the text, you could alternatively use LTRIM() or RTRIM() respectively. That's it, TRIM away!
http://www.aspwebpro.com/aspscripts/records/removingspaces.asp
No comments:
Post a Comment