0
$('#ad_pd_form').bootstrapValidator({ 
    fields: {   
     ad_pd_url: { 
      validators: { 
       notEmpty: { 
        message: 'Please enter a Valid URL' 
       } 
      } 
     } 
    } 
    }) 

我需要限制用戶在文本框中輸入特殊字符。我使用引導驗證器來驗證上述代碼中的表單。用戶只能輸入URL。通過引導驗證器限制文本框中的特殊字符

我該如何限制進入它的特殊字符?

回答

0

使用正則表達式來限制驗證

var nospecial=/^[^*|\":<>[\]{}`\\()';@&$]+$/; 
validators: { 
      notEmpty: { 
       message: 'Please enter a Valid URL' 
      }, 
      regexp: { 
       regexp: nospecial, 
       message: ' ' 
      } 
     } 
0
$('#ad_pd_form').bootstrapValidator({ 
    fields: {   
     ad_pd_url: { 
      validators: { 
       notEmpty: { 
        message: 'Please enter a Valid URL' 
       }, 
       // Url Validation 
       uri: { 
         message: 'The website address is not valid' 
        } 
      } 
     } 
    } 
    }) 
特殊字符