girish_327
Posts: 108
|
| Posted: 06/05/2006, 7:06 AM |
|
Hi All,
I need a littilebit Help from forum members. I have Editable Grid and I want validate each Input box using Javascript.
The validation is I want check the input is Number and it is in between some range like 0 -40. But this validation is different to each Inputbox.
Please help me.
_________________
Girish Baraskar
Web Designer/Developer
http://www.agnisdesigners.com
http://www.eindianpaintings.com
http://www.realestatekolhapur.com |
 |
 |
marcwolf
Posts: 361
|
| Posted: 06/08/2006, 4:56 PM |
|
Hi Girish
Ok - its pretty simple to do.
If you want to do the checking interatively then you can use the 'this' property to pass the instance of the control to a routine.
In JS you can do this (puesdocode follows)
function valnum(obj){
if (obj.value <= 0 or obj.value >41) then
_________________
' Coding Coding Coding
Keep Those Keyboards Coding.
Raw Code!!!!!!!
|
 |
 |
marcwolf
Posts: 361
|
| Posted: 06/08/2006, 4:59 PM |
|
Sorry - Hit submit
In JS you can do this
function valnum(obj){
if <obj.valur <= 0 or obj.value >41) then
alert("Invalid value");
return false
end if
}
Now in CCS you can add in the OnChange("javascript:valnum(this)") into the texbox's HTML or use the formatting section of the property page.
And that should do it.
Take Care
Dave
_________________
' Coding Coding Coding
Keep Those Keyboards Coding.
Raw Code!!!!!!!
|
 |
 |
WKempees
|
| Posted: 06/08/2006, 5:03 PM |
|
function valnum(obj){
if <obj.value <= 0 or obj.value >41) then
alert("Invalid value");
return false
end if
}
|
|
|
 |
marcwolf
Posts: 361
|
| Posted: 06/11/2006, 3:45 AM |
|
Thanks Walter...
Late night plus head cold does not a programmer make :>
Take Care
Dave
_________________
' Coding Coding Coding
Keep Those Keyboards Coding.
Raw Code!!!!!!!
|
 |
 |
wkempees
Posts: 1679
|
| Posted: 06/11/2006, 5:01 AM |
|
Dave, no problem.
Girish you are PM-ing me, Dave is the creator, I just corrected a typo.
I send your PM to him.
Walter
_________________
Origin: NL, T:GMT+1 (Forumtime +9)
CCS3/4.01.006 PhP, MySQL .Net/InMotion(Vista/XP, XAMPP)
if you liked this info PAYPAL me: http://donate.consultair.eu
|
 |
 |
marcwolf
Posts: 361
|
| Posted: 06/12/2006, 2:01 AM |
|
I was able to help Girish by suggesting that he use the OnChange event on the client side of the control.
CnChange(this);
By using the 'this' property he was able to pass over each instance of a control to the validation routine for processing.
Hope this helps others..
Dave
_________________
' Coding Coding Coding
Keep Those Keyboards Coding.
Raw Code!!!!!!!
|
 |
 |
girish_327
Posts: 108
|
| Posted: 06/30/2006, 5:03 AM |
|
<script type="text/JavaScript">
function check_range(obj1){
// Get the value from the object
var value1 = obj1.value;
if (value1 < 0 || value1 > 40){
alert("Invalid Marks Claimed. Must be between 0 and 40.");
return false;
}
var value2 = obj2.value;
if (value2 < 0 || value2 > 20){
alert("Invalid Marks Claimed. Must be between 0 and 20.");
return false;
}
var value3 = obj1.value;
if (value3 < 0 || value3 > 20){
alert("Invalid Marks Claimed. Must be between 0 and 20.");
return false;
}
var value4 = obj1.value;
if (value4 < 0 || value4 > 20){
alert("Invalid Marks Claimed. Must be between 0 and 20.");
return false;
}
var value5 = obj1.value;
if (value5 < 0 || value5 > 30){
alert("Invalid Marks Claimed. Must be between 0 and 30.");
return false;
}
}
</script>
Hi All,
while I am using above code on onChange Event but I am enable to validate every Textfiled. Please tell me whats wrong in above code.I want validate Every Textfeild with different range in Editable Grid.
_________________
Girish Baraskar
Web Designer/Developer
http://www.agnisdesigners.com
http://www.eindianpaintings.com
http://www.realestatekolhapur.com |
 |
 |
marcwolf
Posts: 361
|
| Posted: 07/01/2006, 7:34 PM |
|
Hi Girish.
Sorry - been a bit busy lately and still looking at your other code.
One of the sly things about HTML is that you can add you own attributes into it..
For example
<input type="Text" name="first" id="first" class="ctrl" value="" minrange=0 maxrange=50 >
Now - in your Javascript you can use this
var value1 = obj1.value;
var min1 = obj1.minrange;
var max1 = obj1.maxrange;
if (value1 <min1 || value1 > max1) {
alert("Invalid Marks Claimed. Must be between " + min1+ " and " + max1 +.");
return false;
}
Hope this helps. Take Care
Dave
_________________
' Coding Coding Coding
Keep Those Keyboards Coding.
Raw Code!!!!!!!
|
 |
 |
girish_327
Posts: 108
|
| Posted: 07/07/2006, 10:11 PM |
|
Hi Dave,
I am not understand using above code How do I validate around 30 Dynamic textboxes (Editable Grid) because In editable grid there is only one texbox we see in the CCS other comes in realtime.
_________________
Girish Baraskar
Web Designer/Developer
http://www.agnisdesigners.com
http://www.eindianpaintings.com
http://www.realestatekolhapur.com |
 |
 |
marcwolf
Posts: 361
|
| Posted: 07/09/2006, 4:52 AM |
|
Hi Girish.
Ok.. questions..
How many text boxes are there in a row?
If you have a textbox in a row that has a range entry of 0 to 50- does the textbox on the next row but same column have the same range limitation?
Please let me know and I will explain better.
Take Care
Dave
_________________
' Coding Coding Coding
Keep Those Keyboards Coding.
Raw Code!!!!!!!
|
 |
 |
girish_327
Posts: 108
|
| Posted: 07/09/2006, 11:21 PM |
|
Hi Dave,
I have Six Different Pages (Admin_Step2.ccp to Admin_Step7.ccp) and Each have different Rows but in each page approx 20-25 rows. On each row same column one textbox and eavery row texbox has a different range validation.
If you look on my page (admin_step2.ccp) there is Header Column and It shows some values in Red Text that is my validation for that particular row.
Hope you will understand my problem.
Thanking you.
_________________
Girish Baraskar
Web Designer/Developer
http://www.agnisdesigners.com
http://www.eindianpaintings.com
http://www.realestatekolhapur.com |
 |
 |
marcwolf
Posts: 361
|
| Posted: 07/10/2006, 1:39 AM |
|
Ok - I have passed on Girish solution to him but I will try and explain what I did so that others might benifit.
In the row I added 2 new hidden texbox controls - setting their control source type to "Code Expression". Tis stop the database update routien from processing this control.
function check_range(obj1){
// Get the value from the object
var value1 = obj1.value;
// Get the Row ID
var rowid = GetRowID(obj1);
// Get minimum and maximun Value
var minValue = document.getElementById('minval' + rowid).value
var maxValue = document.getElementById('maxval' + rowid).value
if (value1 < minValue || value1 > maxValue){
alert("Invalid Marks Claimed. Must be between " + minValue + " and " + maxValue + ".");
return false;
}
}
// Get Editable Grid Row from Control
// Pass Control as object (THIS), returns back string of "_x" where x is row
function GetRowID(Field1){
var fldname = ""; var fldname1 = ""; var fldloc = -1;
fldname = Field1.name; fldloc = fldname.lastIndexOf("_"); // work out the calling field and extract its index
if (fldloc <= 0) {return "";} // Not an Index.. Return a Blank, safe to append to control name
else
{return fldname.substring(fldloc,fldname.length);} // returns back the '_x' where x is the row
}
Now the onchange of the entry textbox passes the textbox instance to the function check_range
This then calls the GetRowID to pass back the row ID. Now all we need to do is to retrieve the values onb the minimum and maximum for the row - and then use it to test the input.
Hope it helps someone else.
Take Care
Dave
_________________
' Coding Coding Coding
Keep Those Keyboards Coding.
Raw Code!!!!!!!
|
 |
 |