I'm not a thief.....really!

Results 1 to 2 of 2

Thread: I'm not a thief.....really!

  1. #1
    Join Date
    Dec 1969

    Default I'm not a thief.....really!

    I was hoping that someone could post some code that would allow me to validate text box entries, ie. to remove invalid characters.<BR><BR>I am writing the users entry into a database, and if the uers enters "&#039;; etc this then screws up the SQL statment and an error occurs.<BR><BR>Any help would be most appreciated!

  2. #2
    Join Date
    Dec 1969

    Default RE: I'm not a thief.....really!

    would you actually like those characters in there if possible though?<BR><BR>How about server side doing <BR><BR>rs("myField") = Replace(request.form("myTextBox"),"""","""""",)<BR ><BR>would that not do the trick?<BR><BR><BR><BR>alternatively here is some code that validates client side that only a list of specified characters are in the text<BR><BR><BR>var checkOK = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvw xyzƒ*ŒŽšœžŸÀÁÂÃÄÅÆÇÈÉÊËÌÍÎ ÐÑÒÓÔÕÖØÙÚÛÜÝÞß*áâãäåæçè êëì*îïðñòóôõöøùúûüýþÿ0123456 789-";<BR> var checkStr = myForm.myTextBox.value;<BR> var allValid = true;<BR> for (i = 0; i &#060; checkStr.length; i++)<BR> {<BR> ch = checkStr.charAt(i);<BR> for (j = 0; j &#060; checkOK.length; j++)<BR> if (ch == checkOK.charAt(j))<BR> break;<BR> if (j == checkOK.length)<BR> {<BR> allValid = false;<BR> break;<BR> }<BR> }<BR> if (!allValid)<BR> {<BR> alert("Please enter only letter and digit characters in the \"myTextBox\" field.");<BR> myForm.myTextBox.focus();<BR> return (false);<BR> }<BR><BR><BR>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts