1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

text field exclusion rules for search function

Discussion in 'C#' started by mfred, Jul 20, 2010.

  1. #1
    I have written a package receiving system. I had to work out code to exclude characters because barcode scanners pick up more information that just the tracking numbers. At the bottom of this post is what I am successfully using to change the text field values on submit of add and edit forms. This code is placed so the the information is changed prior to database entry. This is all good. The current issue is that this prevents scanning packages for searching existing entries, since what has beed saved is different than the barcode scans. I've experimented with variations of this code in my search forms but have difficulties implementing it. Someone suggested that I add a function to change the entry in the text field itself, prior to submitting the search. But I am not sure how to do that. As an example, a FedEx barcode results in 37704697160000034226762471582012 but what was saved into the database was 422676247158 So I need the search field to reformat the entry to the latter. There are several variations of this as can be seen in the add/edit exclusion rules below. Does anyone know how to apply something similar to the text field prior to submitting a form? Thanks in advance.

    Function FormatTrackingNumber(TrackingNo)
    chars = Len(TrackingNo)

    If chars = 32 Then TrackingNo = Mid(TrackingNo,17,12)
    If chars = 33 Then TrackingNo = Mid(TrackingNo,18,12)
    If chars = 19 Then TrackingNo = Mid(TrackingNo,2,18)
    If chars = 21 Then TrackingNo = Mid(TrackingNo,2,20)
    If chars = 14 Then TrackingNo = Mid(TrackingNo,2,13)
    If chars = 31 Then TrackingNo = Mid(TrackingNo,10,22)
    If chars = 30 Then TrackingNo = Mid(TrackingNo,9,22)
    If chars = 11 Then TrackingNo = Mid(TrackingNo,2,10)
    If chars = 29 Then TrackingNo = Mid(TrackingNo,6,9)
    If chars = 28 Then TrackingNo = Mid(TrackingNo,5,9)

    FormatTrackingNumber = TrackingNo
    End function
    mfred, Jul 20, 2010 IP
  2. bencummins

    bencummins Peon

    Likes Received:
    Best Answers:
    Trophy Points:
    You would need to use client side javascript to do this, you can put onSubmit="return myfunction()" in the form tag, and it will called the myfunction() before it sends the form
    bencummins, Jul 21, 2010 IP