Showing posts with label Validators. Show all posts
Showing posts with label Validators. Show all posts

4.8.10

User not to enter Numberor Decimal in textbox..

By AJAX:
http://forums.asp.net/p/1288474/3802854.aspx
-------------
1.How to check if a textbox contains a number

http://bytes.com/topic/asp-net/insights/654366-how-check-if-textbox-contains-number

2. check user not enter decimal value in textbox

txtCourseFee.Attributes["OnKeyPress"] = "javascript:CheckDecimal(event);";

function CheckDecimal(event) {

var isNS4 = (navigator.appName == "Netscape") ? 1 : 0;

if (!isNS4) {
if (event.keyCode < 46 || event.keyCode > 57)
event.returnValue = false;
}
else {

if (event.which < 46 || event.which > 57) return false;
}
}



3.) If textbox contain No number then Blank it.

txtCourseFee.Attributes["onblur"] = "javascript:isNotNumberThenBlank(" + txtCourseFee.ClientID + ");";

function isNotNumberThenBlank1(obj) {
if (obj.value.search(/[^0-9^.^ ]/) != -1) {
obj.value = "";
obj.focus();
alert('Please enter only numeric value');
return false;

}

return true;
}


4.) Confirmation on button click
btnSave.Attributes["OnClick"] = "javascript:return confirmation();";

function ConfirmSave() {
var retVal = confirm("This will save Student information. Do you want to continue ?");
return retVal;
}

16.2.10

validation in input upload

script type="text/javascript"
function Checkfiles(f){
f = f.elements;
if(/.*\.(gif)|(jpeg)|(jpg)|(doc)$/.test(f['filename'].value.toLowerCase()))
return true;
alert('Please Upload Gif or Jpg Images, or Doc Files Only.');
f['filename'].focus();
return false;
};

form action="#" onsubmit="return Checkfiles(this);"
input type="file" name="filename"
input type="submit" value="Go!"

http://www.dynamicdrive.com/forums/archive/index.php/t-37439.html

14.1.10

function Check()
{
if (Page_ClientValidate())
{
if (document.getElementById("ctl00_gbtsContent_chkAgree").checked == false)
{
alert('Please select the checkbox.');
return false;
}
}




}


CssClass="MenuButtonlink" ValidationGroup="Save" OnClick="btnSave_Click"
OnClientClick="return Check();" />

===============================================================================

http://alvinzc.blogspot.com/2006/10/aspnet-requiredfieldvalidator.html

Required field validator on checkbox


==============================================================================
CssClass="MenuButtonlink" ValidationGroup="Save" OnClick="btnSave_Click"
OnClientClick="return Check();" />

===============================================================================

http://alvinzc.blogspot.com/2006/10/aspnet-requiredfieldvalidator.html

17.3.09

Validating Dropdown List using RequiredFieldValidator

http://www.dotnetfunda.com/codes/code80-validating-dropdown-list-using-requiredfieldvalidator.aspx

Message box javascript in c#

http://dotnetslackers.com/articles/aspnet/JavaScript_with_ASP_NET_2_0_Pages_Part1.aspx

"Textarea/textbox multiline" maxlength validation

http://geekswithblogs.net/mahesh/archive/2007/12/27/asp.net-textbox.multiline-maxlength.aspx

30.1.09

upload valid image Validator

asp:RegularExpressionValidator ID="RegularFile" runat="server" ControlToValidate="ProductImageUpload" Display="Dynamic" ErrorMessage="Upload a valid file" ValidationExpression="^.+(.jpg|.JPG|.gif|.GIF)$" ValidationGroup="image">

custom validator for Radcombo and checkbox

CustomValidator ID="CusAccountcard" runat="server" ClientValidationFunction="Valaccountcard"
ControlToValidate="DropDownAccountCard" Display="Dynamic" ErrorMessage="Please select account card"
ValidationGroup="Save" asp:CustomValidator

function Valaccountcard(sender,args)
{

var combo =<%=DropDownAccountCard.ClientID %>;
if(combo.GetText()!="Select")
{
args.IsValid = true;
}
else
{
args.IsValid = false;
}

}



function Validate(sender,args)
{

var combo =<%=ddExpMonth.ClientID %>;
if(combo.GetText()!="Select")
{
args.IsValid = true;
}
else
{
args.IsValid = false;
}
var d=new Date();


}



function ValidateYear(sender,args)
{
var combo =<%=ddExpYear.ClientID %>;
if(combo.GetText()!="Select")
{
args.IsValid = true;
}
else
{
args.IsValid = false;
}

}



function ValidationCheck (sender,args)
{
if(document.getElementById('ctl00_Content1_chkAccept').checked==true)
{

args.IsValid=true;

}
else
{
args.IsValid=false;
}
}

26.10.08

Validators and someuseful data

REGULAR EXPRESSION

Name:Regular Expression validator: user not to enter numeric values in textbox and special character.
([A-Za-z]+[ ])*([A-Za-z]+)*
---------------------------------
Postcode:Regular Expression Validator :user not to enter only special characters.

([A-Za-z]+[0-9])*([A-Za-z]+)*

([A-Za-z]+[0-9])*([A-Za-z]+[0-9])*
-----------------------------------------
Regular Expression for Postcode:
([A-Za-z0-9])*
---------------------------------
mobile number:regular expression for
([0-90-9]+[-])*([0-90-9]+)*
-----------------------------------
mobile number:regular expression for
([0-90-9]+[-])*([0-90-9]+)*
--------------------------------------------------------

mobile number:regular expression with space and hyphen
([0-9]+[- ])*([0-9]+)*
--------------------------------------------------------
Card Number Regular Expression:

([0-9])*
==========================================================
Password field: enter less than 5 character

----------------------------------
COLLATE SQL_LATIN1_General_CP1_CS_AS
-----------------------------------------