Jump to content

Adding a string to a textbox


Truly
 Share

Recommended Posts

Hi guys, really stupid question for you.I am validating a textbox, making sure that no one has '.' or '/' in it. If its true that neither of those characters exist then I want it to add '.php' to the end but I cant remember how. Im thinking it would be something like this:document.formname.textboxname=.documnent.formname.textboxname+".php"Im more of a php guy myself so any help would be appreciated :).

Link to comment
Share on other sites

I would recommend adding the id attribute to your form elements (ie <input type="text" name="txtField" id="txtField"/>)Then you can do this

var txt = document.getElementById("txtField");txt.value = txt.value + ".php";

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...