I am trying to add a string to a string, but i can't seem to get it work.
Here is the code:
<input type="text" name="text" id="text">
<input type="button" id="button" value="Click">
And javascript
var htmlYes = false;
$("#text").keydown(function(){
if(!htmlYes){
var value = $("#text").val();
value += ".html";
$("#text").val(value);
htmlYes = true;
}
});
$("#button").click(function() {
var fileName = $("#text").val();
fileName = fileName.replace(".html", "")
alert(fileName);
});
What i am trying to do is, when user starts typing the name of the file he want to export, i want that automaticly ".html" is attached to the end of string he is writing.
But whats happening, the .html is attached to the start. i tried concat(), but nothing seems to work. Any help?
So when i write test, it actually looks like .htmltest but i want to to look like test.html