Link to home
Start Free TrialLog in
Avatar of CPOINT2000
CPOINT2000Flag for United States of America

asked on

ASP vb.net validation question

I have written a VB net web program.  That does the validation in VB.  However this causes problem with screen re-draw.  My undesrtanding is I need to do this in client side, as a script?  I have numerous fields that check for content, size and in some cases content value is based on other fields on the form.

I have the following vb code for example field,
************************************************
        If mxorg = 0 Then
            If istextwflen(org.Text, 3) = False Then
                MsgBox("ORG can only be 3 character text value!")
                org.Focus()
            Else
                org.Text = UCase(org.Text)
            End If
        Else
            org.Text = "***"
        End If

************************************************
And the ASP side has this;
************************************************
                <td class="specialPanelPositionStyle">
   
                    <asp:TextBox ID="org" runat="server" CssClass="smalltxtbox"
                        MaxLength="3" ToolTip="Enter a 3 Character Origin value." CausesValidation="False">
                       
                        </asp:TextBox>    
                </td>
************************************************
I do not want the build in validation because that puts asterix and message on form.  I want a pop up box.  Do I do this in script? or is there some code I can write in ASP section as shown above?

Sorry if I am not clear.
Thanks
Avatar of sammySeltzer
sammySeltzer
Flag of United States of America image

Why not do this on the database side?

Set up your fieldname and give it a character lenght of 3.

Then first of all, then this will look more like this:

                <td class="specialPanelPositionStyle">
   
                    <asp:TextBox ID="org" style="width: 3x;" runat="server" CssClass="smalltxtbox"
                        MaxLength="3" ToolTip="Enter a 3 Character Origin value." CausesValidation="False">
                        (max characther: 3)                      
                        </asp:TextBox>    
                </td>
ASKER CERTIFIED SOLUTION
Avatar of sammySeltzer
sammySeltzer
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of CPOINT2000

ASKER

Thanks I will try this suggestion.  Actually size is not an issue, that is already setup on field.  I need to validate to make sure, it is text, or date, or numeric.  In some cases it has to allow blank and or values.  In some validations (for example date from/to field) need to validate field is valid yyyymmdd ad the from is prior to to date, to date is after from date, etc...  Instead of at time form is submitted I like to validate as field lost focus or is changed.  This is a vb program that is already been out for some time, which is being converted to web application, and I am trying to keep same functionality as possible as PC version.  That's why I am insisting on client side validation.  Reason I placed the ASP code there is that was generated by system for the field, I was trying to see if there was any code I could insert in there, case, if condition etc...  However I will try the script example you provided now.  Thanks
Thanks sorry got side tracked, just got back into code.  This worked.