Question

I have created an external list and in the new form I have a few input controls. Some of them are required fields but are not indicated as such on page. So I am trying to check if the input is empty and show a message that they need to fill it in. But the problem is that once the button is clicked it immediately sends the user the list. So, how can I cancel the click event if the fields are empty?

$('#ctl00_ctl40_g_9068430e_e259_454c_8cfa_f5a629496c52_ctl00_toolBarTbl_RightRptControls_ctl00_ctl00_diidIOSaveItem').click(function()
{

    var descText = $('#Description_$TextField').val();
    if(descText=='')
    {

        $('#Description_$TextField').append('<p>Please enter a description</p>');
        return false;
    }
});
Était-ce utile?

La solution

What you are looking for is called PreSaveAction(). This function allows to override behavior for a Save button. See here for more info:

http://www.ilikesharepoint.de/2014/06/sharepoint-presaveaction-helps-for-actions-before-saving-an-item/

Licencié sous: CC-BY-SA avec attribution
Non affilié à sharepoint.stackexchange
scroll top