You can detect your form mode in JavaScript using the following syntax:
':IsNewMode'':IsEditMode'':IsDisplayMode'
For example:
if ':IsNewMode' { alert('Form is in New mode');}if ':IsEditMode' { alert('Form is in Edit mode');}if ':IsDisplayMode' { alert('Form is in Display mode');}