I have been trying to remove duplicate whitespace from textbox before the data is submitted to database. I have tried TRIM()
function in MySQL, like
cmd.CommandText = "INSERT INTO table1 VALUES TRIM(('" + textBox1.Text + "', '" + textBox2.Text + "'))";
it did not work. I also tried this
textBox1.Text = textBox1.Text.Replace(" ", " ");
I added above code to the submission button which works but it only removes whitespace if it appears twice, as in, double space. In a case where the user input more than two spaces, how do I implement it?
For example: "Hello World"
should be submitted as "Hello World"