how to enable a text box to accept decimal values using javascript/jquery
<p>i have made a small app using javascript and html. </p>

<p>But recently i encountered a problem with my script.</p>

<p><strong>Problem :</strong> Input text box are not allowing me to enter  (.)dot/periods i.e decimal values. Example: if i enter a decimal value then it is automatically deleting from my input text box. </p>

<p>What could be reason for this.</p>

<p>I am trying to solve this issue from last 3hrs. But could not found the exact problem. Please check my code and help me to solve this problem.</p>

<p>Relevent code: </p>

<pre><code>&lt;table border="0"&gt;
    &lt;form name="form_A" onsubmit="return false"&gt;
        &lt;tr&gt;
            &lt;td&gt;
                &lt;select name="unit_menu" class="Items" onchange="CalculateUnit(this.form, document.form_B)"&gt;
                    &lt;option&gt;
                    ------- Select a Property -------
                                                                    &lt;option&gt;
                    &lt;option&gt;
                    &lt;option&gt;
                    &lt;option&gt;
                    &lt;option&gt;
                &lt;/select&gt;

            &lt;/td&gt;
            &lt;td&gt;
                &lt;input type="text" id="info" name="unit_input" placeholder="Type to convert" class="textbox" onfocus="CalculateUnit(this.form, document.form_B)" onkeyup="CalculateUnit(this.form, document.form_B)"&gt;&lt;/td&gt;

        &lt;/tr&gt;
    &lt;/form&gt;
    &lt;form name="form_B" onsubmit="return false"&gt;
        &lt;tr&gt;

            &lt;td&gt;
                &lt;select name="unit_menu" class="Items" onchange="valuefocus()"&gt;
                    &lt;option&gt;
                    ------- Select a Property -------
                    &lt;option&gt;
                    &lt;option&gt;
                    &lt;option&gt;
                    &lt;option&gt;
                    &lt;option&gt;
                &lt;/select&gt;&lt;/td&gt;
            &lt;td&gt;
                &lt;input type="text" name="unit_input" size="20" maxlength="20" placeholder="Type to convert" class="textbox" onfocus="CalculateUnit(this.form, document.form_A)" onkeyup="CalculateUnit(this.form, document.form_A)"&gt;&lt;/td&gt;
            &lt;td&gt;&lt;/td&gt;
        &lt;/tr&gt;
    &lt;/form&gt;
&lt;/table&gt;
</code></pre>

<p>Javascript</p>

<pre><code>         function CalculateUnit(sourceForm, targetForm){
            // A simple wrapper function to validate input before making the conversion
            var sourceValue = sourceForm.unit_input.value;

            // First check if the user has given numbers or anything that can be made to
            // one...
            sourceValue = parseFloat(sourceValue);
            if ( !isNaN(sourceValue) || sourceValue == 0){
                // If we can make a valid floating-point number, put it in the
                // text box and convert!
                sourceForm.unit_input.value = sourceValue;
                ConvertFromTo(sourceForm, targetForm);
            } else {
                 //wrong input
            }
        }
</code></pre>
