locked
Form Validation RRS feed

  • Question

  • Hi,

    I'm starting a dynamics project and hit my first hurdle.

    I need to be able to stop a form from being submitted if the user clicks any of the save buttons.  Have can I cancel the OnSave event after it has started?

    Thanks,

    Steve Hewison
    Its better than fishing a pond
    Wednesday, September 30, 2009 8:01 AM

Answers

  • on the onsave event of the form, add these lines:

    event.returnValue = false;

    I assume you will put some business logic in your onsave javascript, otherwise, your users won't never be able to save forms...

    More over, if you need to know which type of save has been triggered, follow this blog link : http://mscrmtools.blogspot.com/2009/01/jscript-know-which-action-raised-onsave.html


    My blog : http://mscrmtools.blogspot.com You will find: Form Javascript Manager (export/import javascript from forms) ISV.Config Manager (graphical ISV.config edition - export/import) View Layout replicator (customize one view and replicate to others) And others (use tool tag on my blog)
    Wednesday, September 30, 2009 8:04 AM
    Moderator

All replies

  • on the onsave event of the form, add these lines:

    event.returnValue = false;

    I assume you will put some business logic in your onsave javascript, otherwise, your users won't never be able to save forms...

    More over, if you need to know which type of save has been triggered, follow this blog link : http://mscrmtools.blogspot.com/2009/01/jscript-know-which-action-raised-onsave.html


    My blog : http://mscrmtools.blogspot.com You will find: Form Javascript Manager (export/import javascript from forms) ISV.Config Manager (graphical ISV.config edition - export/import) View Layout replicator (customize one view and replicate to others) And others (use tool tag on my blog)
    Wednesday, September 30, 2009 8:04 AM
    Moderator
  • Hi Steve,

    you can use following in OnSave() form property.

     

     

     

    	// Cancel the save operation.
    	event.returnValue = false;
    	return false;


    I hope this wil help you.

    Regards,
    Bhavika Patel

    Wednesday, September 30, 2009 8:06 AM
  • Yeah,

    The form is going to fire an AJAX request.  But if the request fails it's important that the record does not get inserted into the database.

    Thanks,

    You'd of the thought the programming dynamics book would of covered that. LOL
    Its better than fishing a pond
    Wednesday, September 30, 2009 8:07 AM