2011-07-05 33 views
1

当仅在必填字段中输入空格时,验证将被绕过,它假定数据已输入到字段中,其中实际为空。ValidationEngine - 插入空格时绕过验证

任何建议/解决方案?

在此先感谢。

+0

您准确使用哪个验证插件? – jerluc

+0

可能重复[jquery窗体验证不允许空间用户名字段?](http://stackoverflow.com/questions/2942325/jquery-form-validate-not-allow-space-for-username-field) – Balanivash

+0

我是使用jQuery验证引擎 http://www.position-absolute.com/articles/jquery-form-validator-because-form-validation-is-a-mess/ –

回答

0

jQuery有修剪开头和结尾的空格(API - jQuery Trim)一个不错的功能

jQuery.trim(stringToTrim); 

将返回字符串没有空格。

请注意,您也可以使用正则表达式来完成此操作。