• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 601
  • Last Modified:

alert/msgbox in validator using vb.net

hi all,

i have several validators (for ex:RequiredFieldValidator, RegularExpressionValidator, etc) to check user input. the problem is, it has ErrorMessage property that WRITES the warning on the screen instead of popping it up like what usual alert/msgbox does. i don't want a written message, i want an alert/msgbox!!!! =( =(
i've read that it's not possible to do it in asp.net since it's server-side scripting, and i've been suggested to do it in javascript.

however, can anybody help me doing it in vb & asp .net? thx a bunch!
0
lalok
Asked:
lalok
  • 4
  • 3
1 Solution
 
iboutchkineCommented:
If not your validation criteria then

If (Not Me.IsStartupScriptRegistered("Startup")) Then
     Me.RegisterStartupScript("TestMsg",  _
          "<script language='javascript'>alert('Test message...');</script>")
End If


End if
0
 
lalokAuthor Commented:
to iboutchkine>>
How to write the validation criteria? *i'm sorry, my knowledge of JavaScript is not that good*

here's how i do the validation for date format
===========================================================

<asp:RegularExpressionValidator Id="revDate" ControlToValidate="txtDate" ErrorMessage="Wrong Date Format!" ValidationExpression="^(((0[13578]|10|12)([-./])(0[1-9]|[12][0-9]|3[01])([-./])(\d{4}))|((0[469]|11)([-./])([0][1-9]|[12][0-9]|30)([-./])(\d{4}))|((02)([-./])(0[1-9]|1[0-9]|2[0-8])([-./])(\d{4}))|((02)(\.|-|\/)(29)([-./])([02468][048]00))|((02)([-./])(29)([-./])([13579][26]00))|((02)([-./])(29)([-./])([0-9][0-9][0][48]))|((02)([-./])(29)([-./])([0-9][0-9][2468][048]))|((02)([-./])(29)([-./])([0-9][0-9][13579][26])))$" Display="Dynamic" RunAt="Server" />

===========================================================

Here, validation criteria is written in "ValidationExpression" and "ErrorMessage" will write the message on the screen if "ValidationExpression" is violated.
What I want to do is: how to show an alert/msgbox showing the message instead of having it written on the screen?
0
 
iboutchkineCommented:
Is not it  easier to put it under some event (button click ot other)

If not IsDate(myDate) then
If (Not Me.IsStartupScriptRegistered("Startup")) Then
    Me.RegisterStartupScript("TestMsg",  _
         "<script language='javascript'>alert('Test message...');</script>")
End If
End if
0
Granular recovery for Microsoft Exchange

With Veeam Explorer for Microsoft Exchange you can choose the Exchange Servers and restore points you’re interested in, and Veeam Explorer will present the contents of those mailbox stores for browsing, searching and exporting.

 
lalokAuthor Commented:
what kind of validation IsDate() method use? i have to validate it based on dd-mm-yyyy (16-04-2003) expression.
0
 
iboutchkineCommented:
IsDate checks for valid date depending on the regioanl setting on your PC. In my case it is MM/dd/yyyy
0
 
lalokAuthor Commented:
i've put lcid=2057 (british) for dataformatstring so that date will be treated as dd-mm-yyyy though what i need is dutch dataformatstring.
is it enough?

i don't know my pc's regional setting *can't think due to brain freeze*
0
 
lalokAuthor Commented:
announcement:
It's been a while since I made this thread and I've already solved the problem by myself. I'm using validation summary instead of javascript.

This is how I do it:
<asp:ValidationSummary RunAt="Server" ShowSummary="False" ShowMessageBox="True"/>
Also, I've assigned CausesValidation = True to my button/linkbutton so that whenever a user forgets to fill at least 1 webcontrol, a messagebox will appear.

Thus, I'd like to announce that I'm going to ask admin to lock my question.

to jboutchkine: thx very much for your help.
0
 
MindphaserCommented:
Points refunded and moved to PAQ

** Mindphaser - Community Support Moderator **
0

Featured Post

Free learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

  • 4
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now