Showing posts with label Text Box. Show all posts
Showing posts with label Text Box. Show all posts

Saturday, May 10, 2014

JQuery Allow specific number of Alphabets into text box in asp.net

Title:Allow only number of Alphabets in to Text box in asp.net using JQuery

Description:
As per previous article ,we have done validation on the text box which has to hold some value while doing the insertion.Now i would like describe and give an example on JQuery validation ,which will allow only 10 characters into text box.So here i will put condition text box length while performing the validation i:e is less then 10 ,it will show error message through alert box

Example:
<html>
<head runat="server">
<script type="text/javascript" src="Javascript/jquery-1.3.1.min.js"></script>
<script type="text/javascript" language="javascript">

$(document).ready(function() {

$('#allowOnlyChars').click(function() {

if ($("#OnlyChars").val().length < 10) {

alert('Valid data'+"#OnlyChars").val());

return true
}
else {
alert('Please: you should enter only 10 characters')
return false;
}
})
});
</script>
</head>
<body>
<form id="validateForm" runat="server">
<asp:TextBox ID="OnlyChars" runat="server"></asp:TextBox>
<asp:Button ID="allowOnlyChars" runat="server" Text="Validate" OnClick="allowOnlyChars_Click" />
</form>
</body>
</html>

Monday, April 28, 2014

JQuery validate textbox in asp.net


Title : How to validate text box using JQuery in asp.net

Description : Why we have to apply validation on input control?Because of this functionality we can restrict the input data as per our need.Now we will see how to do the validation using client side script(JQuery).If we want to develop the validations in asp.net we have to use validation 
control for specified control.

Example:
<html>
<head runat="server">
<script type="text/javascript" src="Javascript/jquery-1.4.1.min.js"></script>
<script type="text/javascript" language="javascript">
$(document).ready(function() {
$('#doValidate').click(function() {
if ($("#allowData").val()!="") {
alert('Enter Text'+"#allowData").val());
return true
}
else {
alert('Please enter valid data')
return false;
}
})
});
</script>
</head>
<body>
<form id="form1" runat="server">
<asp:TextBox ID="allowData" runat="server"></asp:TextBox>
<asp:Button ID="doValidate" runat="server" Text="Validate" OnClick="doValidate_Click" />
</form>
</body>
</html>


Tuesday, August 6, 2013

Bind data to Asp.net text box using dropdownlist in jquery

Title: JQuery set text box value in asp.net

Description:
In recent articles we known how to implement the  Data binding concept on data  controls like grid view,Data list,list etc.Here i would like to explain how to bind data to asp.net text box while leave the focus on Drop Down List using JQuery blur function.The blur function will fire when the previous controls has lost focus.

Example:
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Bind data to Asp.net text box using DropDownList in jquery</title>
</head>
<script type="text/javascript" src="~/jquery.min.js" ></script>
<script>
$(document).ready(function() {
$("#ddlSalesOrder").blur(function(){
var SalesOrderText = $("#ddlSalesOrder option:selected").text();
 alert(SalesOrderText);
$("#<%= txtOrderTotalAmt.ClientID %>".val(SalesOrderText); 
});
});
</script>
</head>
<body>
Amount: <asp:DropDownList ID="ddlSalesOrder" runat="server">
<asp:ListItem>100</asp:ListItem>
<asp:ListItem>125</asp:ListItem>
<asp:ListItem>150</asp:ListItem>
<asp:ListItem>175</asp:ListItem>
<asp:ListItem>200</asp:ListItem>
</asp:DropDownList>
TotalAmount:<asp:TextBox ID="txtOrderTotalAmt" runat="server"></asp:TextBox>
</body>
</html>
As you can see there is alert to confirmation for drop down selected value will come when the blur event occurs.Whenever we are using JQuery ,we should add JQuery library reference to our application.
In the above example we have taken one drop down list and text box to display the amount order .When the amount Drop down list has lost the focus ,the total Amount will be populate automatically.

Monday, July 29, 2013

Bind data to Asp.net text box using jquery

Title: JQuery bind data to asp.net text box using Blur function

Description:
As per previous articles we have gone through different kind of data binding examples using jquery in asp.net.Now here we will learn about the usage of jquery functionality for web control.

Example:
Now i would like give an example to set the data to Text box in asp.net using jquery.This application will use to  set the food orders.As per requirement we need to assign the value to text box control based on food category Id.To accomplish this task  i have utilized  Jquery script function i:e Blur() which make the functionality what ever we used inside of it

$(document).ready(function() {
$("#<%= txtOrderList.ClientID %>").blur(function(){
var orderList = $(this).val();
$("#<%= txtOrderList1.ClientID %>".val(orderList); 
});

The above script will will bind the data to text box when the other text box focus has moved.You can use this functionality as per requirement very quickly.
This article may help you a lot..Keep visit my website

Sunday, April 1, 2012

Allow only numeric or Characters to Textbox

Title:How to allow only Numeric (Numbers) or Characters to Text box in asp.net

Description:
As per previous articles we have seen how to do this kind of functionality using JQuery . Now i would like to explain how to do with asp.net using vb.net.Here an event procedure will be executed before key value is applied to text box.This event procedure allowed developer to kill the functionality of key.
Example:
//keypress event
msgbox("keypresslogic")
msgbox(e.Keychar&" "&Asc(e.Keychar)
If Asc(e,Keychar)=8 Then
Exit sub
EndIf
//To allow numeric
If(char.IsDigit(e.Keychar)=Flase Then
e.Handled=True
MsgBox("enter numeric)
EndIf
EndSub

Bel