html 从表单字段中排除特殊字符
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了html 从表单字段中排除特殊字符相关的知识,希望对你有一定的参考价值。
<script>
ijQuery(document).ready(function(){
ijQuery.validator.addMethod( 'example', function( value, element ) {
var chars = /[. , ; : ‘ “ ( ) & % $ < >]/g;
if( value.match(chars))
{
return false;
}
else
{
return true;
}
} );
var label = 'Finance Amount';
ijQuery( 'form [name="' + base64_encode( label ) + '"]' ).addClass( 'example' );
ijQuery.extend( ijQuery.validator.messages,{ example: 'field contains illegal characters.'} );
});
</script>
以上是关于html 从表单字段中排除特殊字符的主要内容,如果未能解决你的问题,请参考以下文章