|
Sorry for my mistake..I dont repeat this
Thanks
|
|
|
|
|
I have a ajax tool calendarExtendarFromDate,imgFromDate,textBoxFromDate,calendarExtendarToDate,imgToDate and textBoxToDate,When a date is selected from calendarExtendarFromDate,that date is displayed in textBoxFromDate.Likewise in the case of calendarExtendarToDate.Here is the source code:
--------------------------------------------------------------
<asp:UpdatePanel ID="UpdatePanel1" runat="server"> <asp:TextBox ID="txtFromDate" runat="server" ReadOnly="True"> <img id="imgFromDate" runat="server" src="~/images/calendar.png" alt="~/images/calendar.png"/>
<cc1:CalendarExtender ID="CalendarExtenderFromDate" runat="server" CssClass="cal" TargetControlID="txtFromDate" PopupButtonID="imgFromDate"/> </cc1:CalendarExtender
<asp:TextBox ID="txtToDate" runat="server" ReadOnly="True" Enabled="False"<img id="imgToDate" runat="server" src="~/images/calendar.png" alt="~/images/calendar.png"/> <cc1:CalendarExtender ID="CalendarExtenderToDate" runat="server" OnClientDateSelectionChanged="CheckForFutureDate" CssClass="cal" TargetControlID="txtToDate"PopupButtonID="imgToDate"/>
-------------------------------------------------------------
I have radiobuttons..When the radiobutton between is clicked,then only calendarExtendarToDate is enabled.otherwise it becomes in disabled state..I wrote code in jscript as below:
function validate()
{
document.getElementById("imgToDate").disabled=false;
document.getElementById("txtToDate").disabled=false;
}
//call this function in .aspx.cs as below:
rbBetween.Attributes.Add("onClick", "return validate()");
textbox is disabled.When between radio is clicked,then only enabled.But calendarextendar disabled didnt work.Pls help me...
|
|
|
|
|
Please don't cross post. Posting at multiple forums is considered rude. Pick one forum and stick to it.
Cross Post[^]
|
|
|
|
|
..may as well be me!
This is perhaps a little cheeky to ask, but hey... my JavaScript skills are functional (shall we say)
but I've never really mastered it... in particular, the use of arrays....
I have a FileUpload control, fu2, with the following attribute added in code behind:
fu2.Attributes.Add("onchange", "checkFile(this)")
which call this verification function in my JavaScript file:
function checkFile(what){
var source=what.value;
if (source!='') {
var i = source.lastIndexOf("\\");
var j = source.lastIndexOf(".");
var fName = source.substring(i+1,j);
var ext=source.substring(source.lastIndexOf(".")+1,source.length).toLowerCase();
if ( ext=='doc' || ext=='docx' || ext=='pdf' || ) {
var regex = /^[A-Za-z0-9_ -]{1,50}$/;
if (!regex.test(fName)) {
alert('The file name contains illegal characters, or is too long\nPlease re-name the file using only alphanumeric charcters, hyphens, spaces and underscores\nand restrict it to a maximum of 50 characters\n' + fName);
}
} else {
alert('Please upload only files of the following types:\n .doc, .docx, .pdf');
}
}
}
As you can see, this attempts to limit both the file types the user can upload, and also the file name.
And actually, it all works well enough - but I know it could be written so much better...
I feel that the "list" of allowable file types should be an array, and the test made
against that, as well as the alert message built out of it - thus making the code that
much easier to maintain if the list changes. Arrays.. hmm.. this is where I get stuck...
plz, it's not urgentz, but if anyone is feeling generously inclined....
|
|
|
|
|
NeverHeardOfMe wrote: I feel that the "list" of allowable file types should be an array, and the test made
against that
<html><head><script>
var fileTypeAllowed = (function(){
var ar = arguments;
return function(arg){
for(var i = ar.length;i--;){
if(arg == ar[i]){return true;}}
return false;
};})('doc','docx','pdf');
alert(fileTypeAllowed('docx'));
alert(fileTypeAllowed('docxa'));
</script>
</head>
<body>
hi
</body></html>
modified on Tuesday, September 14, 2010 12:44 PM
|
|
|
|
|
See... I knew it would be obvious....
Thanks
(Sorry for not marking your answer as "Good" - done now!)
modified on Friday, July 23, 2010 4:19 AM
|
|
|
|
|
NeverHeardOfMe wrote: See... I knew it would be obvious....
Thanks
There is nothing obvious about that code
|
|
|
|
|
Just to let you know, you spelt characters wrong in the alert() function
NeverHeardOfMe wrote: only alphanumeric charcters, hyphens, spaces
|
|
|
|
|
Ta.. I love typos - I do them all the time!
|
|
|
|