If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

Hybrid View

Variable illegalChar doesn't clear

I want the following function to validate a user input. It's fairly crude for the moment but essentially I want to prohibit the user from either leaving the input blank, or from entering single quotes that truncate the user input when it goes into sql.

I'm not actually sure how to sandwich a single quote within two other single quotes so for now I've used a dash - I'm sure I can figure that out but if someone knows I'd appreciate being told. This isn't the main problem however.

The main problem I'm having is as follows:

Consider the scenario that the user does enter a Dash. This is picked up by the script and the user is informed. The user then removes the dash. However when they next click the button to validate their input they are told once again that there is a dash in the input value.

For some reason the 'illegalChar' variable is not clearing and I'm confused as to why?

Use a '\'' (with a backslash before the single quote) or "'" (with two double quotes for delimiters) for a single quote and call the function addCommodCheck with a onblur on this input.
An other solution, with utf-8, consists to use the true apostrophe ’ (alt 0146) and to replace all singles quotes with this apostrophe with something like :

The main problem I'm having is as follows:
Consider the scenario that the user does enter a Dash. This is picked up by the script and the user is informed. The user then removes the dash. However when they next click the button to validate their input they are told once again that there is a dash in the input value.
For some reason the 'illegalChar' variable is not clearing and I'm confused as to why?