Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Split textbox into 3 areas

Tags:

html

jquery

css

I want to split my text box into three areas eg: I want values to be displayed like 951-05-8765456. Is there a way to display the "-" by default after 3 places and so when the user enters the value it will be split automatically.I want my text box to be as in the image Splitted Text Box

like image 216
BlackPOP Avatar asked Dec 17 '13 11:12

BlackPOP


People also ask

How do I split text in a text box?

Right-click the text box, placeholder, or shape border, and click Format Shape. Click Columns, enter the number of columns in the Number box, and the space between each column (in inches) in the Spacing box.

Can you split a text box in Word?

Objects like textboxes can't be split over multiple pages in Word. You might want to consider using a single cell table instead. Table cells can split over multiple pages and you can set the properties so that text is wrapped around them. Was this reply helpful?

Can you split a text box in Powerpoint?

Click the AutoFit Options tool at the lower-left corner of the placeholder box. Select Split Text Between Two Slides or Continue on a New Slide. A new slide is created immediately after the current one. Split Text ...


2 Answers

Basically you can't do with only CSS, so you can use this jquery plugin and you do it easily.

Mask Plugin

You can use this plugin for your textbox as follow:

$(".TEXT_BOX_CLASS").mask("9999/99999/99999");
like image 198
Parixit Avatar answered Oct 05 '22 02:10

Parixit


<!DOCTYPE html>

<html lang="en" xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="utf-8" />
    <title></title>
    <script src="http://code.jquery.com/jquery-1.10.1.min.js"></script>
    <style type="text/css">

    </style>
</head>
<body>
<input type="text" class="mynum" value="" />

<script type="text/javascript">   


    $('.mynum').keydown(function () {
        var value = $('.mynum').val();
        var len = value.length;        
        if (len == 4)
            value += '/';
        if (len == 10)
            value += '/';
        if (len == 16)
            return false;
        $('.mynum').val(value);
    });



</script>

</body>
</html>
like image 20
kundan Karn Avatar answered Oct 05 '22 00:10

kundan Karn