Thursday, May 28, 2009

Stop CRM Form Save

Here I give you an example of what code you might want to consider to achieve the CRM form from saving as you could either use
  • event.returnValue = false; or
  • return false;
To know what's the difference between the two, click on the links below.

Code : alert('You clicked C Drive.'); event.returnValue=false;
Code : event.returnValue=false; alert('You clicked Drive C.');

Observe the above two code and their behavior. When you click on C Drive, you receive an alert box and then the function returns false whereas when you click Drive C the function returns false first but then still goes ahead to and displays the alert.

When you just return false, you will notice a different behavior. Try the below links:

Code : alert('You clicked C Drive.'); return false;
Code : return false; alert('You clicked Drive C.');

This time when you click on C Drive, you receive an alert box and then function returns false whereas when you click Drive C the function returns false and the alert isn't displayed.

I believe with this information you are better equipped on what to use and when.