I'm using CKEditor. To check if there's a value or not, I tried to use RequiredFieldValidator.
The RequiredFieldValidator works but not perfectly, I need to make sure the CKEditor doesn't contain anything, not even white-space.
The RequiredFieldValidator works when I type 1 or 2 space(s).
When I click the space button a third time and then click the submit button, the RequiredFieldValidator considers it valid, and data is posted.
So I created a CustomValidator, in the validation method, I remove all HTML tags, then I .Trim(), however, trimming isn't working, data is still posted, and even if I do field.Text.Trim().Length; the returned number isn't 0.
What needs to be done here?
The method that removes HTML tags.
public string StripTagsCharArray(string source)
{
char[] array = new char[source.Length];
int arrayIndex = 0;
bool inside = false;
for (int i = 0; i < source.Length; i++)
{
char let = source[i];
if (let == '<')
{
inside = true;
continue;
}
if (let == '>')
{
inside = false;
continue;
}
if (!inside)
{
array[arrayIndex] = let;
arrayIndex++;
}
}
return new string(array, 0, arrayIndex);
}