hey all.

I am trying to do validation via PHP for submitted forms. Below is my own code, please comment if its the correct method or not.

However, I tried so many ways to have the /n or /r added, but I cant get to it.

Its just to make a new paragraph. Currently, it does the validation, but once I hit the enter key twice, for a new paragraph, it doesnt work the way it should.

Any help and advice appreciated.


function validateText($data){
		//if it's NOT valid
		if(ereg('[^a-zA-Z0-9 .,-_]', $data))
			return false;
		//if it's valid - Must contain only alphabetical characters a-z, numerical numbers 0-9, spaces, commas, fullstops, dashes and underscores (abc123 ,._-)
			return true;

thanx man.

in regards with the other post, no its not.

I am submitting plain text, and I just want to know how to alter the ereg syntax so that it will allow the /n/r tags too.

I got it working in javascript, but I dong get the solution for php validation.


thanx @ mschroeder

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.