I am adding two textbox value and show result in third text box on button click.
I restrict user add maximum and minimum value into rate restriction textboxes.
On that restriction user add the rate between the maximum and minimum value.
If value entered below or above then show message. All works perfectly and show a hardcode message but I want it show dynamically message. Like if I enter maximum value=75.0 and minimum value = 30.0
Now I enter below rate or above it show message please enter rate between 30.0 to 75.0
If maximum value=100
Minimum value =50
Then user entered above or less value show that message please enter rate between 50 to 100.
Please help me how I show dynamically message on behalf of entered value into textboxes.
Can’t show the hardcode message
alert("User Cannot enter Rate between 45.0 to 70.0 ");
Following my html and js code.
HTML Code
<div>
<td>
<asp:Label ID="Label1" runat="server" Text="Set Rate"
style="font-weight: 700; color: #6699FF;"></asp:Label>
</td>
</div>
<div>
<td>
<asp:Label ID="Label2" runat="server" Text="Maximaum Rate "></asp:Label>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
</td>
</div>
<div>
</td>
<asp:Label ID="Label3" runat="server" Text="Manimum Rate"></asp:Label>
<asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
</td>
</div>
<div>
<td>
<asp:Label ID="Label4" runat="server" Text="Sum Operation"
style="font-weight: 700; color: #3399FF"></asp:Label>
</td>
</div>
</div>
<div>
<td>
<asp:Label ID="Label5" runat="server" Text="Quantity "></asp:Label>
<asp:TextBox ID="TextBox3" runat="server"></asp:TextBox>
</td>
</div>
<div>
</td>
<asp:Label ID="Label6" runat="server" Text="Rate"></asp:Label>
<asp:TextBox ID="TextBox4" runat="server"></asp:TextBox>
</td>
</div>
<div>
</td>
<asp:Label ID="Label7" runat="server" Text="Result"></asp:Label>
<asp:TextBox ID="TextBox5" runat="server"></asp:TextBox>
</td>
</div>
<div>
<td>
<input id="Button2" type="button" value="Sum" onclick="return add();" />
</td>
</div>
Js Code
function add() {
var FirstRestrication = $("[id*=TextBox1]").val();
var SecondRestrication = $("[id*=TextBox2]").val();
var val1 = parseInt($("#TextBox3").val());
var val2 = parseInt($("#TextBox4").val());
if (FirstRestrication > val2) {
if (SecondRestrication < val2) {
$("#TextBox5").val(val1 + val2);
}
}
else
{
alert("User Cannot enter Rate between 45.0 to 70.0 ");
}
$("[id*=TextBox3]").val('');
$("[id*=TextBox4]").val('');
$("[id*=TextBox1]").val('');
$("[id*=TextBox2]").val('');
};
please help me how i solve it