I have a single textarea that I need to validate - once it is confirmed 'not empty' I want to replace the text entered into the same textarea onSubmit because after this is done there are a series of checkboxes to add.

So something like this - which doesn't work because everytime I add 'else' or even 'else if' the validation is always true for some reason:

function checkText() {
var frm = document.textAdd;

if (frm.inputtext.value == "") {
alert("You must add some text");
return false;

}else {

form.inputtext.value = 'text';


<form name="textAdd" action=<?PHP echo $_SERVER['PHP_SELF']; ?> method="post" onSubmit="return checkText();">

<textarea name="inputtext" value="text"></textarea>

Can I input the 'value' back into the textarea on the first submit in case of an edit after the boxes are checked?

Only when the last isset isset($_POST['whatever']) is true can I then capture what is in the textarea and insert it into the db - do I need to convert the final text area to PHP?

I'd rather not use jQuery because I'm only using one text box and I don't need a very complicated code setup.