Link to home
Start Free TrialLog in
Avatar of axa905
axa905

asked on

Remove first 3 characters

I'm not very good at Javascript, I'm using Dreamweamer's built in form validation and the problem is the error message is using the input field name instead of value, so for example it's using "txtName" instead of just "Name".

"nm"  here is representing my input field name. All my field names have an extra 3 characters (like 'txt') at the begining. Can I somehow add something to this line of code and have those preceding first 3 letters removed from nm in the below line of code?

errors+='- '+nm+' must contain an e-mail address.\n';


Thank you so much.
Avatar of nschafer
nschafer
Flag of United States of America image

Hi axa905,

Try this,

errors+='- '+ nm.substring(3,nm.length-3) +' must contain an e-mail address.\n';


Hope this helps,
Neal.
SOLUTION
Avatar of pzepernick
pzepernick

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Avatar of Zvonko
Zvonko
Flag of North Macedonia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial