hello, I loaded data from DB and print it in form: query = mysql_query("SELECT cont FROM `some_table` WHERE id = $id "); $index = mysql_fetch_array($query); $cont = $index['cont']; echo "<form method='post' action='index.php'> <textarea name='description' value='$cont'>$cont</textarea> </form>"; PHP: I want the script to compare the content of value $cont with the new text that I'll write in the TEXTAREA I need it to be on the client side, means - when I click SUBMIT, the script will be run and will giving me massage if the text in the TEXTAREA was change (not equal to value $cont). Thank you all in advanced, Roi.
create a hidden variable where the value is also $cont then put a listener on the page which looks for change in the description box and puts up an alert if the hidden variable != to the textbox value
To compare the value in the textarea, use the below code: Add a method “comapreValues(dbValue)†on the onSubmit event of the form. And add the below code in javascript block. Function comapreValues(jsValue){ currentValue=document.getElementByName(‘description’).value; if(currentValue != jsValue){ alert(‘value mis-matched.’); document.getElementByName(‘description’).focus(); return false; } Return true; }