WAP validation or Wapalidation by Michael Wright

Contributed by
Rating: 4 stars4 stars4 stars4 stars4 stars / 3
November 07, 2000
Rate this Article:
MEH MEH++


SEARCH ASP FREE
TOOLS YOU CAN USE

advertisement

Validate your WAP pages with Wapalidate

Many of the unsupported characters within WAP pages are created using website contributors whereby users (webmasters etc) add content via WEB forms which transform custom MS Word characters into HTML code characters e.g. &#8216. These HTML code characters are then stored in databases which when displayed on WAP pages can create compilation errors.

Wapalidate is a function that can be used to validate strings or database fields so that they compile correctly. This will hopefully help WAP developers to lower the chances of compilation errors and using the same databases for both WEB and WAP sites.

Here is the code:

Function Wapalidate(strToCheck)

' Replace unsupported characters e.g. HTML code characters

strToCheck = Replace(strToCheck,"‘","'")

strToCheck = Replace(strToCheck,"’","'")

strToCheck = Replace(strToCheck,"“","'")

strToCheck = Replace(strToCheck,"”","'")

strToCheck = Replace(strToCheck,"–","-")

strToCheck = Replace(strToCheck," ","&")

strToCheck = Replace(strToCheck,"&"," ")

' Use the above line to add extra unsupported characters

' Replace(strToCheck,"CHANGE THIS","AND WHAT IT WILL BECOME")

Wapalidate = strToCheck

End Function

 

To use the function:

Wapalidate(VARIABLE NAME) e.g. Wapalidate(Article)

Wapalidate(FIELD NAME) e.g. Wapalidate(rs("Article"))

Another way to avoid compilation errors is to make sure that if you are retrieving a large amount of data from a database, that it will not make the output WAP page more than 1440 bytes.

Here is a snippet of my code:

LOS = Len(Article)

' Display Headline

%>

<p align="left"><small><b><%=Headline%></b></small></p>

<%

‘ Display Article

' If there are more than 500 characters in string

nospace = 0

If LOS > 500 Then ‘ change 500 to anything you like but think about the 1440 bytes per page

chars = 500 ‘ change 500 to the same as above

Do while nospace = 0

' Retrieve characters from article

tempArticle = Left(Article,chars)

If Right(tempArticle,1) = " " then

nospace = 1

' Set tempArticle to Article

Article = tempArticle

Else

nospace = 0

chars = chars + 1

End If

Loop

' Calculate amount of characters left

More = LOS - chars

' Display 500 characters within article

response.write("<p align='left'><small>"&Article&"...</small></p>")

' Link to view more of the article

%>

<do type="accept" label="More"><go href="NEXT WAP PAGE TO DISPLAY MORE" method="post"><postfield name="id" value="<%=id%>"/><postfield name="more" value="<%=More%>"/></go></do>

<%

Else

' Display full article

response.write(Article)

End If

To display the remainder on the NEXT WAP PAGE:

Get the Article strings data again from the database using the id variable and then calculate the remainder by Article = Right(Article,more) then something like

<p align="left"><small>...<%=Article%></small></p>. Don’t forget to retrieve the id and more variables first.

Please do not contact me on the above code as I will not reply (I expect you to mess around with the code yourself). If you wish to contact me on updates to the Wapalidate function or job opportunities then please e-mail michael_wright@lineone.net.

blog comments powered by Disqus
CODE EXAMPLES ARTICLES

- Bipartite Graphs
- Connectivity in Graphs
- The Ford-Fulkerson Algorithm
- Critical Paths
- The Bellman-Ford and Roy-Floyd Algorithms
- Shortest Path Algorithms in Graphs
- Minimum Spanning Tree
- Articulation Edges and Vertexes
- Circles and Connectivity in Graphs
- Depth-First Search in Graphs
- Breadth-First Search in Graphs
- The Prufer Code and the Floyd-Warshall Algor...
- An Insight into Graphs
- Coding a Custom Object with WSC
- Creating a Custom Object with WSC

ASP Web Hosting ASP.Net Web Hosting Windows Web Hosting
 
 
 

ASP Free Forums 
 RSS  Tutorials RSS
 RSS  Forums RSS
 RSS  All Feeds
Site Map 
Request Media Kit
Write For Us Get Paid 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
Privacy Policy 
Support 


© 2003-2012 by Developer Shed. All rights reserved. DS Cluster 8 - Follow our Sitemap
Most Popular Topics
All ASP.Net Tutorials