Click here to Skip to main content
15,897,187 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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.
Posted
Updated 7-Nov-16 22:42pm
Comments
F-ES Sitecore 7-Nov-16 8:55am    
Client validation? Server validation? Both? How are you configuring the validation you currently have?

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
 
Share this answer
 
try this validation using jquery

JavaScript
var text = $('#textboxId').val();
        if ($.trim(text) == '')
        {
            alert('Please enter the valid data');
            return false;
        }
 
Share this answer
 
Client side jquery validation.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900