I am working on a script where one or more of the fields in a form, all of which are required fields, contain a default value of just a single hypen. Ideally, the people completing the form would erase the hypen when entering the actual data. Things being as they are, though, I know that things are not always ideal.
I know how to check the field length to see if anything was entered in the field or to see if nothing was entered but the hyphen was erased (which should not be). My problem is when the person enters some text but fails to erase the hypen first.
Theoretically, the hypen could end up as the first character of the text or the last character of the text, depending on how they entered the rest of the text, or it may not be there at all. In addition, the entered text itself may contain a hyphen that needs to be there.
Question: how can I tell the script to check for a hyphen as the first or last character of text in a field and remove it if the field contains other data without removing any hyphen in any other position within the text?
Any help will be appreciated.
I know how to check the field length to see if anything was entered in the field or to see if nothing was entered but the hyphen was erased (which should not be). My problem is when the person enters some text but fails to erase the hypen first.
Theoretically, the hypen could end up as the first character of the text or the last character of the text, depending on how they entered the rest of the text, or it may not be there at all. In addition, the entered text itself may contain a hyphen that needs to be there.
Question: how can I tell the script to check for a hyphen as the first or last character of text in a field and remove it if the field contains other data without removing any hyphen in any other position within the text?
Any help will be appreciated.