locked
Disable Save RRS feed

  • Question

  • Hi All,

    I have 2 fields ok?? 1 is for Cost and 1 is for Price...... What I am doing is the following:

    Onsave event of the form

    var prodCost = crmForm.all.new_productcost.DataValue;
    var unitPrice = crmForm.all.new_priceperunit.DataValue;
    
    if (prodCost >= unitPrice)
    {
    alert ('Cost cannot be equal or greater than Price');
    }
     The problem is that it is still saving........... it do not want it to save if the Cost > than price... how can I do that??

    Regards
    Monday, February 22, 2010 2:03 PM

Answers

All replies

  • Hi All,

    I have 2 fields ok?? 1 is for Cost and 1 is for Price...... What I am doing is the following:

    Onsave event of the form

    var prodCost = crmForm.all.new_productcost.DataValue;
    var unitPrice = crmForm.all.new_priceperunit.DataValue;
    
    if (prodCost >= unitPrice)
    {
    alert ('Cost cannot be equal or greater than Price');
    }
     The problem is that it is still saving........... it do not want it to save if the Cost > than price... how can I do that??

    Regards
    Monday, February 22, 2010 2:02 PM
  • Hi

    In the Onsave event use

    alert(event.Mode);

    to prevent from saving.

    Regards
    Vinoth
    Monday, February 22, 2010 2:07 PM
  • U can also use

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


    Regards
    Vinoth
    Monday, February 22, 2010 2:12 PM
  • // Cancel the save operation.
          event.returnValue = false;
          return false;


    Regards
    Vinoth
    Monday, February 22, 2010 2:19 PM