0
votes

I want to show a modal dialog/pop-up window when the user has not filled in a text field on the page, instead of using an error text field on the page.

If the required text field is filled in, I want the submit button to work as normal (aka call the onClick function), but if it's not filled in, I want a dialogue window/modal pop-up to show up stating that they need to fill in the specific field.

What's the best way of this?

I personally prefer using the jquery ui library over the ajax control toolkit modal popup if possible.

1
I think a way of intercepting a button click and performing js before the postback is what I'm looking for - user clicks button, js determines whether to cancel the normal functioning (the onclick function) or not.stringo0

1 Answers

2
votes

All that you have to do is to do the following.

  1. Create a JS function that does the validation, display the dialog if it errors. Have that function return true/false if validation is ok or fails.
  2. On your button, add an "onClick" method to the attributes. "javascript: return YourFunction();" and you should be set to go.

The return value of your method will prevent postback if returning false!