|
FWIW: While client-side validation may improve the user experience, you should always have validation on the server-side just to be safe.
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
|
|
|
|
|
I agree that server side validation is safe. still if you wish to proceed then please find below example to validate textbox.
var txtValue = document.getElementById(<"%txt1.ClientID%">).value;
if(txtValue==null || txtValue='')
{
alert('Please enter value in textbox.'); //message should be depends on requirement.
return false;
}
Let me know still if you have any doubts.
Regards
Keyur Satyadev
|
|
|
|
|
Hi,
I want to check if the string ends with '-0000' when all the remaining characters are numbers.
I tried Regex.IsMatch(mystring, @"\d*(0){4}") but it returns true even when there is no '-'
which regular expression to check with for a string which ends with '-0000'
|
|
|
|
|
one more method u can check enter value on server side or in page.
|
|
|
|
|
try [.\-0000] in expression
|
|
|
|
|
This one worked for me:
System.Text.RegularExpressions.Regex.IsMatch(str, @"[.\-]\d*(0){4}");
when tested:
bool b1 = Do("10.0000");
b1 = Do("10-0000");
b1 = Do("10-0000/");
b1 = Do("10-0000.");
b1 = Do("10-0000/-");
where Do() is
private bool Do(string str) { return System.Text.RegularExpressions.Regex.IsMatch(str, @"[.\-]\d*(0){4}"); }
♫ 99 little bugs in the code,
99 bugs in the code
We fix a bug, compile it again
101 little bugs in the code ♫
|
|
|
|
|
|
fififlowertot wrote: when all the remaining characters are numbers
Not sure what you mean by that.
However, the following regex will ensure the string ends with a dash followed by exactly 4 numeric digits.
-[0-9]{4}$
If you want to ensure the whole string is zero or more numeric digits followed by a dash followed by exactly 4 zeroes, this would work:
^[0-9]*-0{4}$
|
|
|
|
|
Hello All,
To accomplish the autocomplete feature into our website, I went through the whole process of setting up AjaxControlToolkit on my computer. I set up a ADD TAB on Visual WEb Developer 2008 Web Express. Added an item and selected this dll. Was able to create the ajax controls.
Now when I set up a new web site, ajax and non-ajax web sites, for some reason I am unable to access these controls. Do I need to add the reference to the ajaxcontroltooklit.dll reference to this new web site project? I can see all the controls but on the design page when I try to drag an icon over, it does not let me .
Thanks!
|
|
|
|
|
|
It is not to with the autocomplete but the entire AjaxControlToolkit.dll itself.
I am unable to reference it any other newer projects, it comes greyed out on the toolbar. Do I need to add a new reference each time I want to use the Ajax controls?
Thnaks.
|
|
|
|
|
that is why I have the Ajax Toolkit in a special folder. So each project can Find it (for the components left). Of coure you have to reference the dll in each project
In Word you can only store 2 bytes. That is why I use Writer.
|
|
|
|
|
Hi all, I need help validating textBox whether the user input was a correct date format and not empty. I can use RequiredFieldValidator to make sure the textbox is not empty but how do I know is correct date format which support my database.thanks,
|
|
|
|
|
Why not use a calendar control rather than a textbox? The date will already be formatted.
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
<cc1:CalendarExtender ID="CalendarExtender1" runat="server" TargetControlID="txtTodate"
Format="dd MMM yyyy">
</cc1:CalendarExtender>--%><br />
<asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" ControlToValidate="txtTodate"
ErrorMessage="Invalid Format" ValidationExpression="^((31(?!\ (Feb(ruary)?|Apr(il)?|June?|(Sep(?=\b|t)t?|Nov)(ember)?)))|((30|29)(?!\ Feb(ruary)?))|(29(?=\ Feb(ruary)?\ (((1[6-9]|[2-9]\d)(0[48]|[2468][048]|[13579][26])|((16|[2468][048]|[3579][26])00)))))|(0?[1-9])|1\d|2[0-8])\ (Jan(uary)?|Feb(ruary)?|Ma(r(ch)?|y)|Apr(il)?|Ju((ly?)|(ne?))|Aug(ust)?|Oct(ober)?|(Sep(?=\b|t)t?|Nov|Dec)(ember)?)\ ((1[6-9]|[2-9]\d)\d{2})$"
ValidationGroup="AddEmp"></asp:RegularExpressionValidator>
Hope this can help you.
|
|
|
|
|
thanks much for you help. Please can you put the code in different format so that I can see it. I can't see all the code.
thanks again.
|
|
|
|
|
|
Hi,
I have a grid which is bound to data coming from a service at runtime.
The issue is every time i select next page number the page goes blank.
My code is as follows: for grid in aspx
<div>
<asp:Label ID="Label1" runat="server" Text="Searching....." Font-Bold = "true"></asp:Label>
<asp:GridView ID="grid1" runat="server" OnPageIndexChanging= "grid1_PageIndexChanged"
AutoGenerateColumns="False" Enabled ="false" AllowPaging="True" PageSize="5">
<Columns>
<asp:BoundField DataField = "Name"/>
<asp:BoundField DataField = "ID"/>
</Columns></asp:GridView>
</div>
the codebehind(.cs) is typically is as follows:
on pageload:
grid1.Enabled = true;
DataTable dt = new DataTable();
dt.Columns.Add("Name");
dt.Columns.Add("ID");
dt.Rows.Add("Jack", 1);
dt.Rows.Add("Jill", 2);
dt.Rows.Add("Jack", 1);
dt.Rows.Add("Jill", 2);
dt.Rows.Add("Jack", 1);
dt.Rows.Add("Jill", 2);
dt.Rows.Add("Jack", 1);
dt.Rows.Add("Jill", 2);
dt.Rows.Add("Jack", 1);
dt.Rows.Add("Jill", 2);
dt.Rows.Add("Jack", 1);
dt.Rows.Add("Jill", 2);
dt.Rows.Add("Jack", 1);
dt.Rows.Add("Jill", 2);
dt.Rows.Add("Jack", 1);
dt.Rows.Add("Jill", 2);
grid1.DataSource = dt;
grid1.DataBind();
protected void grid1_PageIndexChanged(Object sender, GridViewPageEventArgs e)
{
grid1.PageIndex = e.NewPageIndex;
grid1.DataBind();
}
what am i missing here
|
|
|
|
|
I think you need to include your Page_Load code inside If( ! PostBack ) { } block.
Please try this.
♫ 99 little bugs in the code,
99 bugs in the code
We fix a bug, compile it again
101 little bugs in the code ♫
|
|
|
|
|
yes my code is inside if (!IsPostBack) block..
but evrytime i click say page 2 the screen goes blank.
|
|
|
|
|
I can't reproduce this behaviour. When paging through the Grid the screen doesn't go blank. Im using VS 2010.
Maybe it has something to do with the data source you've bound to the control?
|
|
|
|
|
my datasource is a list of objects returned from the service.
Since I need to format it before displaying I convert it into a datatable and this datatable is datasource to the grid. I have stepped thru and found that datatable has populated fine with all the values. even the page comes up fine with all the data and 123 page links down. it's when i click page 2/3 link in pager that it goes blank. am using vs 2008 .net 3.5
|
|
|
|
|
You should probably separate all the three subroutines. Have the !(PagePostback), datagrid itself, and the Grid1_PageIndexChanging all separate and not in one sub.
|
|
|
|
|
my page load checks if it's not postback it calls the gridview load which does what i've posted and i have seperate event handler.
|
|
|
|
|
I had the same issue. I had to literally re-bind the entire datagrid for it to work. It worked for me, and was working under time cruch, I stuck with it.
|
|
|
|
|
what do u mean by rebind, rewrite the code?
|
|
|
|