Mvc:没有文本的文本框中的空格考虑数据 [英] Mvc : space in text box without text considers data
问题描述
你好,
MVC:
我有一个文本框,认为文本框中包含所有空格作为有效数据,它允许保存记录,虽然它有验证。它应该只允许使用一些文本空间。
如何防止将空间作为有效数据?
谢谢。
我的尝试:
你好,
MVC:
我有一个文本框,它将所有空格都视为有效数据,并允许保存记录虽然它有验证。它应该只允许使用一些文本空间。
如何防止将空间作为有效数据?
谢谢。
Hello,
MVC :
I have a text box which considers text box with all space as a valid data and it allows to save the record though it has validation on it. it should allow space only with some text.
how can I prevent allowing full space as a valid data?
Thanks.
What I have tried:
Hello,
MVC :
I have a text box which considers text box with all space as a valid data and it allows to save the record though it has validation on it. it should allow space only with some text.
how can I prevent allowing full space as a valid data?
Thanks.
推荐答案
是的,Jquery验证器必需属性接受空格作为字符并通过验证。
因此,您需要自定义所需属性或将自己的属性添加到验证器。
请检查以下链接:
jQuery Validation自定义验证不添加空间验证 [< a href =http://stackoverflow.com/questions/8101920/jquery-validation-custom-validation-adding-no-space-validationtarget =_ blanktitle =New Window> ^ ]
谢谢
Yes the Jquery validator required attribute accepts space as a character and does pass the validation.
So you need to customize the required attribute or add your own attribute to the validator.
Please check the link below:
jQuery Validation custom validation adding no space validation [^]
Thanks
使用jquery尝试此验证
try this validation using jquery
var text =
(' #textboxId')。val();
if (
('#textboxId').val(); if (
这篇关于Mvc:没有文本的文本框中的空格考虑数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!