Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Validate Textarea Data Problem when Check If Data was Edited

Status
Not open for further replies.

Coder7

Programmer
Oct 29, 2002
224
US
Good afternoon.

I have an html textarea that I use as input for an Edit function. Upon clicking the submit button, I call a javascript validate function that checks (1) if the text was changed and (2) if the textarea isWhiteSpace. The only thing that can be edited on the form is the data that's in the textarea.

I define a variable in the javascript to hold the 'original' text. Then I move the value of the VBscript variable that holds the 'original' text into the javascript variable. Then, in the javascript, I check the 'new' value of the form's textarea against the javascript 'original' text variable value and, if the text is the same, I display message indicating that the text was not changed and I return focus to the textarea.

Is there another way to perform this validation that is easier - I'm have trouble with the vbscript variable when it's concatenated into the javascript variable in the javascript. A carriage control was throwing a " onto a new line and I was getting an error that my variable string was missing the closing " and what we've tried thus far as solutions isn't working and I don't think onchange is a good option here.

As always, thanks for any assistance.







 
I think the comparison method you are doing sounds like your best bet and what I would go with. It's bullet proof in the validation will always be correct and not be fooled by adding spaces to the original contents etc..

I would only add one thing to the conditions though. as I said before on being fulled by the user hitting spacebar or something. trim the variables and even take out all spaces contained with in the textarea contents to ensure this instance cannot occur I dare to learn more
admin@onpntwebdesigns.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top