Paste Splitter

Apr 12, 2005

<html>
<head>
<title>Paste Splitter v1.0</title>
<style type="text/css">
body, input {
font: normal 12px Verdana;
}
</style>
<script type="text/javascript">
/************************
Paste Splitter v1.0
Glenn G. Vergara
glenngv@yahoo.com
Philippines


NOTE:
Please make this intact
if you want to use this
script. Thanks.
*************************/

function PasteSplitter(origMaxlen){ //you can also pass as many field references as needed in the argument
var me = this;
var arglen = arguments.length;
this.flds = new Array();
this.maxlen = origMaxlen;
this.filter = this.NUMERIC; //default filter
for (var i=1; i<arglen; i++){
this.flds[i-1] = arguments[i];
}
if (this.flds.length > 0){
var fld1 = this.flds[0];
fld1.onkeydown = function(event){
extendMaxLength(me.flds, me.maxlen, event);
}
fld1.onkeyup = function(event){
splitPaste(me.flds, me.maxlen, event)
}
if (typeof fld1.onbeforepaste != "undefined"){
fld1.onbeforepaste = function(event){
extendMaxLength(me.flds, me.maxlen, event);
}
}
if (typeof fld1.onpaste != "undefined"){
fld1.onpaste = function(event){
//we need a little delay here before calling the function
setTimeout(function(){
splitPaste(me.flds, me.maxlen, event);
}, 10);
}
}
}

function extendMaxLength(arrFlds, maxlen1, evt){
if (!evt) evt = event;
if (evt.ctrlKey || evt.type=="beforepaste"){
var len = maxlen1;
var arrlen = arrFlds.length;
for (var i=1; i<arrlen; i++){
len += arrFlds[i].maxLength;
}
arrFlds[0].maxLength = len + arrlen - 1; //allow separators in beetween sets (e.g. - . /)
}
}

function splitPaste(arrFlds, maxlen1, evt){
var s = arrFlds[0].value;
//apply filter
switch (me.filter){
case me.NUMERIC:
s = s.replace(/D/g, "");
break;
case me.ALPHANUMERIC:
s = s.replace(/W/g, "");
break;
case me.ALPHA:
s = s.replace(/[^a-zA-Z]/g, "");
break;
default: //custom filter
s = s.replace(me.filter, "");
}
var len = s.length;
if (len <= maxlen1){
arrFlds[0].value = s;
if (arrFlds.length > 1 && len==maxlen1){
arrFlds[1].focus();
}
return;
}
else {
var len=0, start=0, arrlen=arrFlds.length, el;
for (var i=0; i<arrlen; i++){
el = arrFlds[i];
len = (i>0) ? el.maxLength:maxlen1;
el.value = s.substr(start, len);
if (el.value=="" || el.value.length < len){
el.focus();
el.value = el.value; //this trick puts cursor at the end of value after focusing on the field first
return;
}
start += len;
}
}
arrFlds[0].maxLength = maxlen1; //change back to original maxlength
}
}

//filters
PasteSplitter.prototype.NUMERIC = 1;
PasteSplitter.prototype.ALPHANUMERIC = 2;
PasteSplitter.prototype.ALPHA = 3;

PasteSplitter.prototype.setFilter = function(filter){ //custom filter (regexp) may be specified
this.filter = filter;
}
/***************end of script******************/



//SAMPLE USAGE
function init(){
var f = document.forms[0];

//serial number
var ser = new PasteSplitter(f.ser1.maxLength, f.ser1, f.ser2, f.ser3); //pass the original maxlength of the first field and all the references of as many fields as needed
ser.setFilter(ser.ALPHANUMERIC); //set filter to alpha-numeric

//sss number
var sss = new PasteSplitter(f.sss1.maxLength, f.sss1, f.sss2, f.sss3, f.sss4); //default filter (numeric) will be used
}
window.onload = init;
//END OF SAMPLE USAGE

</script>
</head>
<body>
<form>
<h1>Paste Splitter v1.0</h1>
<p>Copy any alpha, numeric or alphanumeric characters, even including separators such as slash (/), hyphen (-), dot (.) or anything, and then paste it in the first field. The characters will be split to all the fields automatically excluding the separator. Very useful for fields like serial number, Social Security number, telephone number and the like. The script works on the basis of the <code>maxlength</code> attribute of the field. It degrades well for JavaScript-disabled browsers, making the <code>maxlength</code> attribute untouched. It works well for IE for all paste commands (<code>CTRL+V</code>, <code>Edit->Paste</code>, <code>right-click->Paste</code>) and partially works for Firefox (<code>CTRL+V</code> only).</p>
<fieldset>
<legend>Information</legend>
<label for="ser1">Serial No.</label> <input type="text" maxlength="5" size="5" id="ser1" name="ser1" /> - <input type="text" maxlength="4" size="4" id="ser2" name="ser2" /> - <input type="text" maxlength="6" size="6" id="ser3" name="ser3" /><br />
<label for="sss1">SSS No.</label> <input type="text" maxlength="2" size="2" id="sss1" name="sss1" /> - <input type="text" maxlength="7" size="7" id="sss2" name="sss2" /> - <input type="text" maxlength="2" size="2" id="sss3" name="sss3" /> - <input type="text" maxlength="1" size="1" id="sss4" name="sss4" />
</fieldset>
</form>
</body>
</html>

If you have any comments, suggestion, bugs found, please feel free to post them here.

View 10 Replies


ADVERTISEMENT

JQuery :: Mouse Paste Binding Won't Fire - UI Autocomplete - Keyboard Paste Is Fine

Jul 7, 2011

My paste catch trigger for autocomplete works fine for Ctrl-V. If using right click/paste, however, it will not trigger autocomplete. The paste event does fire with both keyboard and mouse, but for some reason it's not triggering the autocomplete, but again - Only with the mouse paste.

View 1 Replies View Related

JQuery :: Splitter Not Working Over Iframe?

Mar 14, 2009

I am using the jquery splitter from [URL]My right pane is fully occupied by an iframe. The splitter doesn't work when I try to drag it over the iframe (drag to right) i.e. the iframe does not resize when the splitter is dragged over it, but the same iframe resizes when the splitter is dragged over the left pane (drag to left). The iframe is contained in a div tag as shown in the html below.

<html>
<body>
<div id="left"></div>

[code]....

View 4 Replies View Related

Having A Splitter (image Or A Line) Between Col1 And Col2

Jan 20, 2011

I have my page layout as below:

------------------
frame1
-------------------
****|******

[code]...

I would like to have a splitter (image or a line) between col1 and col2; When i click on it, It should display the cursor as =|= (something similar) and should be able to resize col1 and col2. (I have added * for understanding purpose to display them as separate columns)

View 3 Replies View Related

JQuery :: Paste Event - Get The Value Of The Paste

Feb 22, 2009

I am trying to fix a bug in WYSWYG (NicEdit). When I copy and paste from a site it pulls the styles and elements that are in that copy ~ all I want is just the plain text.

So I am starting a script that can be used to override the paste in the textarea and strip the copy to plain text.

This is what I have so far (it's just a start):

So, when I paste in a texarea right now there is an alert that says "paste". What I want is to get the data in the paste and then strip it to plain text - then paste it in the textarea.

View 2 Replies View Related

Prevent Paste

Sep 29, 2007

I found this handy little script on the net that means the user can only press backspace or numbers in form input.

<script type="text/javascript">
function numbersonly(e){
var unicode=e.charCode? e.charCode : e.keyCode
if (unicode!=8){ //if the key isn't the backspace key (which we should
allow)
if (unicode<48||unicode>57) //if not a number
return false //disable key press
}}
</script>

<form>
<input type="text" size=18 onkeypress="return numbersonly(event)">
</form>

It works, but it's not foolproof.

2 issues with this code.

1) Can I stop a user from accessing my website if he/she is not using
javascript?

2) Can I prevent a user from breaking the code and entering other
stuff by placing the cursor in the box and pressing ctrl+v (paste)

View 3 Replies View Related

Copy And Paste A Div Tag?

Dec 23, 2010

hello how can I copy and paste a div tag ???

View 3 Replies View Related

Copy And Paste

Sep 16, 2005

Is it possible to do this: when clicking a button, info is selected and copied to computers "cache" (don't know exact name) ready for pasting in other application like Word?

View 3 Replies View Related

Paste Only Float Number

Jul 23, 2005

how can i test if I paste in an edit if the new value contains only numbers
and one ',' to test if I paste only a float ???

View 1 Replies View Related

JQuery :: How To Paste Image Into A Web App

Oct 23, 2009

I have a web app (front end jquery, backend django) that allows usersto type commens into a text area. My users are asking for the abilityto cut and paste images into their comments. They want to use anwindows app called mwsnap to basically snap images from their desktop,then ctrl-v to copy the image into my django app. Does anyone knowwhat sort of client side support is needed to do this? I am fairlyadept at jquery/javascript, but haven't seen anything like this thoughit does seem like a very reasonable request since they are certainlyable to cut and paste into Outlook this way. However, when I try tocut and paste this way into yahoo mail or gmail it doesn't work, soperhaps this is a hard thing to do in a web app.

View 2 Replies View Related

JQuery :: Paste An Image Into A Tag?

Sep 17, 2009

This may or may not be possible, but if anyone knows a way to do it,I'd love to hear from you.Basically, I simply (?) want to copy an image (e.g. from ALT-PrintScreen or 'Copy Image'), and paste/drop it into an img tag on a pageso it appears on the page. I can then resize, drag-drop, etc. asrequired.I've had a rummage around the net, but can't find anything. Maybe it's

View 4 Replies View Related

Auto Tab When Copy And Paste?

Aug 10, 2009

How to make a form that automatic tab when we paste something into the box and sort it out automatically. Like cd-key box. When we copy n paste cd-key into the box it automatic inert everything into correct places.

View 3 Replies View Related

Using Cut & Paste Dynamic Combo Box

Jan 31, 2006

I have built my menu as I needed on a seperate asp page and it works beautifilly. Then moved it to my actual web page and it ceases to function. and I am getting an error 'document.doublecombo.SECTOR is Null or object does not exist' I will include the non working piece in the following post, too long for here. Code:

View 1 Replies View Related

Paste A Text Line Using Js?

Dec 19, 2011

I was just doing a simple stuff of executing system copy, delete etc. commands using execCommand method of js.

I have made two textareas, in one i am inputting some text and by hitting on the buttons i am executing copy, cut etc. commands.

Problems::::----

In this the paste button is not working. Like i am copying some text from one textarea, it is not pasting into other textarea.

Also I want to do select all for the textareas only. Like if cursor is on textarea1 and if I am hitting on selectAll button it should only select the textarea1 content. Currently it is selecting the whole page content. code...

View 2 Replies View Related

Paste A Text As A Variable

Mar 23, 2005

for conveniance purposes I was trying to paste a text into a variable assignment:

PHP Code:

var mystring=" hello,
world
how are
you
today"


obviously javascript does not tolerate such syntax...
is ther any way I can get close to that

I am not talking about inserting /n in te string ...

View 3 Replies View Related

Paste A .gpx File Into A Textarea?

Jun 25, 2011

I am trying to paste a .gpx file into a textarea and then look at lines in this format:

Code:
<trkpt lat="34.494383996352553" lon="-89.916610959917307">

In the following j and k are already initialized to zero and my match statements don't even find trkpt, much less the floating point values on that line.

Code:
lines = document.gpxform.InputField.value.split("
");
for (i = 0; i < lines.length; i++) {

[Code].....

View 2 Replies View Related

Copy And Paste Form In Another Frame

Jul 23, 2005

I am trying to copy a form that is in one frame, using a button on another
frame. The form has a couple of tables inside it. I can get it working
when the button is in the same frame, but not in different ones. I get an
"invalid argument" error on the controlRange.addElement(x) line.

What I have so far is:

<script language='javascript'>
function CopyForm() {
if (document.body.createControlRange) {
var x = window.parent.fraRight.document.getElementById('Fo rm1');
x.contentEditable = 'true'
var controlRange;
controlRange = document.body.createControlRange();
controlRange.addElement(x);
controlRange.execCommand("Copy");
x.contentEditable = 'false'
alert('The table is now copied to memory.
Start Excel, and Paste
the table into a new worksheet.');
}
</Script>

where fraRight is the name of the frame the form is in, and Form1 is the
name of the form I want to copy. The only thing I have changed from when it
was working in the one frame, is:

var x = window.parent.fraRight.document.getElementById('Fo rm1');
used to be
var x = document.getElementById('Form1');

I can do things like alert(x.name) and get the right name of the form, so I
think I have got the object properly. Is there any other way to make sure?

View 1 Replies View Related

Disable Paste And Drag Event

Apr 28, 2006

How to disable the copy/drag event for some selected textfield as I want the user to key in instead of copy or drag the required information.

For IE, I done it with the onPaste and onDragEnter Event, but it don't work on Other Browser ...

View 2 Replies View Related

How To Detect A Paste Action On A Textbox?

Dec 2, 2006

Is this possible with Javascript in anyway? :)

View 13 Replies View Related

JQuery :: Copy Paste Not Working?

Jun 4, 2009

I have implemented alpha & alphanumeric plugin in my code.I am doing this validation in few text boxes.my problem is, the text box don't allow copy paste in FireFox.. but its is allowing in IE.. What might be the problem with firefox..?

View 1 Replies View Related

Cut & Paste CSS Horizontal List Menu?

Jan 7, 2010

I am having problems with a script 'Cut & Paste CSS Horizontal List Menu' from [URL]

It works on my site with Firefox but not IE 8.

My site url is [URL]

View 1 Replies View Related

Prevent User Using Ctrl V To Paste?

May 22, 2011

I wish for my users to retype their email address instead of the copy and paste method to ensure they have typed it correctly both times.

How could this be done, would it be Javascript ?

View 6 Replies View Related

Unterminated String Literal From Paste?

Jun 30, 2011

I created a simple WYSIWYG for creating CSS based webpages. It works exactly as assumed in Safari and Chrome. However, in firefox, when you copy/paste more than one line of text, instead of formatting it as html, in puts in line breaks causing the array storing all of the data to break into multiple lines and causing an unterminated string literal.

1. suggest why it is behaving this way?
2. suggest a work around to allow it to work on FF?

View 2 Replies View Related

Check Mouse Paste Event?

Jun 1, 2009

i have two text boxes in Web application. When i enter data in first textbox second will enable automatically. i have written javascrit of onblur and onchanges and onkeyup event to enable the second textbox, it works fine but the problem is when i copied and pate it in first textbox throw the mouse event the second testbox is not enabled.

View 1 Replies View Related

How To Stop User To Do Copy / Paste

Jul 8, 2009

I have busy forum site where some of the spammers copy/paste the forum topics from other sites! I would like to disable copy/paste using Javascript! Its possible? How to do it!

View 5 Replies View Related

Let A User Paste An Image On A Webpage?

May 5, 2010

I want to give the user possibility to paste an image into a webform. I don't need to display the image, all I need is the image's location.I know it's possible because the guys at CKEditor(and other editors) are doing it. If you go here, [URL] and paste an image you copied and then right click on it and go to image properties you'll see they have the image's address. How can this be done?

View 2 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved