I want to add a comma after copy pasting string into input
$("#keywords").bind('paste', function() {
var a=$("#keywords").val();
alert(a);
});
I tried the above code to check if the pasted value is passed into variable. In alert it is displaying empty value. How can i know if the value of the pasted string is passed into variable and then append comma to the variable.
Here is the fiddle
The
pasteevent is fired before the pasted text is available as a value property on the textbox. You need to wait a few milliseconds, and then just add the comma to the value, like so:FIDDLE