Error Trapping for letters

Results 1 to 3 of 3

Thread: Error Trapping for letters

  1. #1
    Adrina Guest

    Default Error Trapping for letters

    I have an input box which is only to accept numbers(id). I want to check for errors just in case a user enters letters (a,s,d). Could someone direct as to how to loop through my text. I tried the mid function but, not successful. This is what i have...<BR><BR>If IsNumeric(mid(reportid, i , 1) or mid(reportid, i ,1) = "," or mid(reportid, i ,1 ) = " ") Then<BR> &#039do nothing<BR>For i = 1 to Len(reportid)<BR> response.write "The id does not exist"<BR>Next<BR>Else<BR> Response.Write "<BR>&#060;b&#062;&#060;font face=&#039Arial, Helvetica, Verdana&#039 size=2&#062; The (" & reportid & ") you entered is not a proper Report_ID. Please go Back and correct your entry.&#060;/b&#062;"<BR>End If

  2. #2
    e Guest

    Default RE: Error Trapping for letters

    you can use this:<BR><BR>&#060;script language=javascript runat=server&#062;<BR>function inStrGrp(src,reg) {<BR> var regex=new RegExp("[" + reg + "]","i");<BR> return regex.test(src);<BR>}<BR>&#060;/script&#062;<BR>&#060;script language=VBscript runat=server&#062; <BR>If inStrGrp(reportid,"a,s,d") = True Then<BR>Response.Write "error message here"<BR>Else<BR>For i = 1 to Len(reportid)<BR>Response.Write "The ID does not exist"<BR>End if<BR>&#060;/script&#062;<BR><BR><BR>hope this helps :)

  3. #3
    Join Date
    Dec 1969

    Default RE: Error Trapping for letters

    You might want to consider using client-side scripting to verify that the field holds numeric data on the client before it is submitted to the server. I have a javascript that will generate a message box telling the user if the field is not numeric, if a required field is empty, if a date field is invalid, or if an email address is incorrect. If you want a copy of it, email me at and I&#039ll send you a copy.

Posting Permissions

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