简体   繁体   中英

Validate field/attribute in CRM Dynamics forms using js

I have a problem in validating attribute on a form in CRM dynamics. I added a JavaScript code that validate the attribute value based on my business rules. and added to 2 events, form on save and field on change,

the question is:

1- Is this the best way to validate on attribute?

2- In case of using this way, how can i stop saving the form or passing it as valid ?

I believe that's a good way to validate input. In case you want to stop save in case one of validations fails do following:

  1. Check "Pass execution context" during registration of save event handler.
  2. Add parameter to function that's called during save procedure.
  3. In case your validation fails call following code:

    execObj.getEventArgs().preventDefault()

You can find more details here - https://msdn.microsoft.com/en-us/library/gg509060.aspx

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM