Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

are there invalid characters for ALERT function? can you check first?

Status
Not open for further replies.

mb22

Programmer
Sep 4, 2002
258
US
i have an alert(MyCommentsTableField) in my code. Problem is sometimes the comments may have special charaters like maybe ( I'll .... we'll ..."" ..... ) and i think then cause the alert funtion not to work.

how can i test for invalid characters and then strip them off before calling the alert function?
 
Is this what ur looking for???

Code:
<html>
<head>

<script language="JavaScript">
function check()
{
	alert(document.testform.name.value);
}
</script>
</head>
<body>

<form action="" method="post" ID="Form1" onsubmit="check();" name="testform">
<input type=text name="name" value="">

<input type=submit value="submit" name="sub">
</form>
</body>
</html>

rsshetty.
It's always in the details.
 
I mean I wasn't sure what element type was MyCommentsTableField - text or table???? Maybe u cud paste the relevant part of ur code !!!

rsshetty.
It's always in the details.
 
No no....... MyCommentsTableField is a "memo" field in Access or "ntext" in SQL2000.

The comments is free format TEXT that is entered in a field just like a normal comment for say a Customer record. Typical comment may be like

"Joe called on 12/8. He's a high risk .... so check credit limit or request "guarantor" ... !!!!!!"

In my query .. I do say
SELECT Cust_Id, Cust_Name, Comments from CUSTOMERTable

if Comments <> ''
alert(Comments)
end if


But because it is free format text ... Comments may contain "invalid" characters ... so I think I want to kind of validate the TEXT or PARSE the text for any characters that may prevent alert(Comments) from working.

Or is there no need for that?
 
just make an array of all the invalid characters which are most likely '"/\;:$ and probably a couple more. In your array you would list each invalid charachter and have the textboxes check the array onpropertychange, and if it finds one of those invalid characters, then it would alert them or some other fansy way...

easy as pie...

__________________________________________________________
"The only difference between me and a mad man is that I'm not mad."
- Dali
 
oh, or you could just use a confirm box. That way you could skip writing the array syntax!

__________________________________________________________
"The only difference between me and a mad man is that I'm not mad."
- Dali
 
Oh ok. Try this.

Code:
SELECT Cust_Id, Cust_Name, Comments from CUSTOMERTable

if Comments <> '' %>
<script language=vbscript>
msgbox(Comments)
</script>
<%
end if

rsshetty.
It's always in the details.
 

There are no invalid characters for an alert box. If your MyCommentsTableField string contains the text, then the alert box routine should show it.

Dan
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top