how to implement JS validation for special characters in sharepoing

how to implement in sharepoint?


To check special characters I think you need JS validation. To do that, just load or inject the following js function into your edit/new form .aspx

function PreSaveAction(){
    var format = /[ !@#$%^&*()_+\-=\[\]{};':"\\|,.<>\/?]/;
    var fldName = 'Title';
    var fldType = 'Text'
    var ctrl = $('[id^='+fldName+'_][id$='+fldType+'Field]');
    if(ctrl && !format.test(ctrl.val())){
       return true;
    }
    return false;
}
regards
metatonkaAsked:
Who is Participating?
All Courses

From novice to tech pro — start learning today.