OnClientSubmit - Stop Submission

3 posts, 0 answers
  1. Dan Ehrmann
    Dan Ehrmann avatar
    152 posts
    Member since:
    Jul 2004

    Posted 27 Mar 2014 Link to this post

    I am performing a test on the editor content in OnClientSubmit. I would like to prevent the submit if the test fails. Is it possible to do this?
  2. Dan Ehrmann
    Dan Ehrmann avatar
    152 posts
    Member since:
    Jul 2004

    Posted 27 Mar 2014 in reply to Dan Ehrmann Link to this post

    replying to myself...

    I should add that I have resolved this by replacing the __doPostBack function to add my test. I just wonder if there is a way to do this without this extra code.
    $(document).ready(function () {
        var originalDoPostBack = __doPostBack;
        __doPostBack = function (target, args) {
            if (hasBadContent(editor.get_html(false))) {
                return;
            }
            originalDoPostBack(target, args);
        }
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Ianko
    Admin
    Ianko avatar
    1535 posts

    Posted 28 Mar 2014 Link to this post

    Hello Dan,

    The proper approach is using a CustomValidator control, which cancels the submit upon to implemented logic.  The editor by itself cannot cancel the submitting and such behavior would be faulty.

    I suggest examining this live example which demonstrates the integration of the CustomValidator with the RadEditor control.

    Regards,
    Ianko
    Telerik
     

    Build cross-platform mobile apps using Visual Studio and .NET. Register for the online webinar on 03/27/2014, 11:00AM US ET.. Seats are limited.

     
Back to Top