-
ChatterFeed
-
0Best Answers
-
0Likes Received
-
0Likes Given
-
6Questions
-
5Replies
Javascript Function for KeyPress
Hi, I need a help. Below javascript function will not allow to enter more than 6 numbers or 4 numbers+'.'+1 number.
But if I have the number as 1234.5 and I delete 1234 then the function is letting me to enter .55555 which shud not happen.
I am not able to find where i went wrong. Can anybody help please?
function OnKeyPress(e,DivID) {
if ( e.which != 8 && e.which != 0 && e.which != 13 && e.which != 46 && (e.which < 48 || e.which > 57)) {
return false;
}
var val = j$('[id$='+DivID+']').val();
if(DivID == 'ProximityCPPercentage')
{
var x = event.which || event.keyCode;
if(val.indexOf('.') >= 0 && e.which == 46)
return false;
else if(e.which == 46 && val.length == 3)
return false;
if(val.indexOf('.') == 0)
val = '0' + val;
if(e.which != 46)
{
strval = val + String.fromCharCode(x);
var re = /^((.|0|[1-9]\d?)(\.\d{1})?|100(\.0?)?)$/;
if(!re.test(strval))
return false;
}
}
else if(val.indexOf('.') > 0)
{
if(e.which == 46 )
return false;
var arra = val.split('.');
var decval = arra[1];
var val = arra[0];
if(val.length > 6)
return false;
if(decval.length > 0)
return false;
}
else if(e.which != 46 )
{
if(val.length > 5)
return false;
}
}
But if I have the number as 1234.5 and I delete 1234 then the function is letting me to enter .55555 which shud not happen.
I am not able to find where i went wrong. Can anybody help please?
function OnKeyPress(e,DivID) {
if ( e.which != 8 && e.which != 0 && e.which != 13 && e.which != 46 && (e.which < 48 || e.which > 57)) {
return false;
}
var val = j$('[id$='+DivID+']').val();
if(DivID == 'ProximityCPPercentage')
{
var x = event.which || event.keyCode;
if(val.indexOf('.') >= 0 && e.which == 46)
return false;
else if(e.which == 46 && val.length == 3)
return false;
if(val.indexOf('.') == 0)
val = '0' + val;
if(e.which != 46)
{
strval = val + String.fromCharCode(x);
var re = /^((.|0|[1-9]\d?)(\.\d{1})?|100(\.0?)?)$/;
if(!re.test(strval))
return false;
}
}
else if(val.indexOf('.') > 0)
{
if(e.which == 46 )
return false;
var arra = val.split('.');
var decval = arra[1];
var val = arra[0];
if(val.length > 6)
return false;
if(decval.length > 0)
return false;
}
else if(e.which != 46 )
{
if(val.length > 5)
return false;
}
}
-
- Subha Ayyappan 7
- June 27, 2016
- Like
- 0
- Continue reading or reply
How can I Order My List as the order of Another List?
Hi ,
I need help in ordering the List. I have a List where the Field Priority__C must be ordered as Primary,Secondary, Tertiary,Fourth,Fifth,Sixth etc.. This order is in another List if Strings.
The user can change the priority of the record, and after resequencing the priority the order must be same again as Primary, Secondary etc...
I tried ORDER BY Id. But when the priority is changed the Id remains same and so not able to get the ordering.
Please help.
I need help in ordering the List. I have a List where the Field Priority__C must be ordered as Primary,Secondary, Tertiary,Fourth,Fifth,Sixth etc.. This order is in another List if Strings.
The user can change the priority of the record, and after resequencing the priority the order must be same again as Primary, Secondary etc...
I tried ORDER BY Id. But when the priority is changed the Id remains same and so not able to get the ordering.
Please help.
-
- Subha Ayyappan 7
- June 22, 2016
- Like
- 0
- Continue reading or reply
The return value of apex method to be used to check a condition in javascript in the visualforce page
Can anybody help me solve this issue?
I want to check if the user selects duplicate value of the picklist when many records are displayed to edit and show the error message and stop if duplicate is found.
I wrote a apex method for the same. Now how to take the return value to check the condition to show the error message in javascript?
My apex method is :
public Integer getcheckDuplicate() {
// RequestsList = new List<Reclassification_Request__c>();
for(integer i=0 ; i<RequestsList.size();i++) {
system.debug('Entering First For Loop');
for( integer j=(i+1) ; j<RequestsList.size() ;j++) {
Reclassification_Request__c reclassreqI = RequestsList.get(i);
system.debug(reclassreqI);
Reclassification_Request__c reclassreqJ = RequestsList.get(j);
system.debug(reclassreqJ);
if(reclassreqI.Request__c != 'Other') {
if(reclassreqI.Request__c == reclassreqJ.Request__c) {
system.debug('Duplicate Found');
// ApexPages.addmessage(new ApexPages.message(ApexPages.severity.WARNING,'Error:Priority may not be duplicated.'));
ErrorCount = ErrorCount+1;
}
}
}
}
return ErrorCount;
}
I want the check the value of ErrorCount and show the error message. But the value is always 0. Why? Any help please...
I want to check if the user selects duplicate value of the picklist when many records are displayed to edit and show the error message and stop if duplicate is found.
I wrote a apex method for the same. Now how to take the return value to check the condition to show the error message in javascript?
My apex method is :
public Integer getcheckDuplicate() {
// RequestsList = new List<Reclassification_Request__c>();
for(integer i=0 ; i<RequestsList.size();i++) {
system.debug('Entering First For Loop');
for( integer j=(i+1) ; j<RequestsList.size() ;j++) {
Reclassification_Request__c reclassreqI = RequestsList.get(i);
system.debug(reclassreqI);
Reclassification_Request__c reclassreqJ = RequestsList.get(j);
system.debug(reclassreqJ);
if(reclassreqI.Request__c != 'Other') {
if(reclassreqI.Request__c == reclassreqJ.Request__c) {
system.debug('Duplicate Found');
// ApexPages.addmessage(new ApexPages.message(ApexPages.severity.WARNING,'Error:Priority may not be duplicated.'));
ErrorCount = ErrorCount+1;
}
}
}
}
return ErrorCount;
}
I want the check the value of ErrorCount and show the error message. But the value is always 0. Why? Any help please...
-
- Subha Ayyappan 7
- June 16, 2016
- Like
- 0
- Continue reading or reply
Trigger to change the field values before deleting
Below is my code to change the Request Field value to after deleting. It works fine, but not all the time. When i delete primary request, the secondary request must be changed to primary and the tertiary must change to secondary.
Sometimes when i delete primary, tertiary is changed to secondary but secondary is not changing to primary. Any idea please.
List<Reclassification_Request__c> lstSecondaryReq =[Select Id,Name,Request__c, MGCRB_CBSA_Code__c from Reclassification_Request__c where Request__c='Secondary Request' LIMIT 1];
List<Reclassification_Request__c> lstTertiaryReq =[Select Id,Name,Request__c, MGCRB_CBSA_Code__c from Reclassification_Request__c where Request__c='Tertiary Request' LIMIT 1];
For(Reclassification_Request__c RR : Trigger.old) {
If (RR.Request__c == 'Primary Request')
{
If (lstSecondaryReq != null && lstSecondaryReq.size() > 0) {
Reclassification_Request__c SecondaryReq = new Reclassification_Request__c();
SecondaryReq = lstSecondaryReq[0];
System.debug('Current Value To Modified '+SecondaryReq.Request__c);
SecondaryReq.Request__c = 'Primary Request';
update SecondaryReq ;
System.Debug('Primary to Secondary Update Completed'+SecondaryReq.Request__c);
}
If (lstTertiaryReq!= null && lstTertiaryReq.size() > 0) {
Reclassification_Request__c TertiaryReq = new Reclassification_Request__c();
TertiaryReq = lstTertiaryReq[0];
TertiaryReq.Request__c = 'Secondary Request';
update TertiaryReq;
}
} else if (RR.Request__c == 'Secondary Request')
{
If (lstTertiaryReq!= null && lstTertiaryReq.size() > 0) {
Reclassification_Request__c TertiaryReq = new Reclassification_Request__c();
TertiaryReq = lstTertiaryReq[0];
TertiaryReq.Request__c = 'Secondary Request';
update TertiaryReq;
}
}
}
Sometimes when i delete primary, tertiary is changed to secondary but secondary is not changing to primary. Any idea please.
List<Reclassification_Request__c> lstSecondaryReq =[Select Id,Name,Request__c, MGCRB_CBSA_Code__c from Reclassification_Request__c where Request__c='Secondary Request' LIMIT 1];
List<Reclassification_Request__c> lstTertiaryReq =[Select Id,Name,Request__c, MGCRB_CBSA_Code__c from Reclassification_Request__c where Request__c='Tertiary Request' LIMIT 1];
For(Reclassification_Request__c RR : Trigger.old) {
If (RR.Request__c == 'Primary Request')
{
If (lstSecondaryReq != null && lstSecondaryReq.size() > 0) {
Reclassification_Request__c SecondaryReq = new Reclassification_Request__c();
SecondaryReq = lstSecondaryReq[0];
System.debug('Current Value To Modified '+SecondaryReq.Request__c);
SecondaryReq.Request__c = 'Primary Request';
update SecondaryReq ;
System.Debug('Primary to Secondary Update Completed'+SecondaryReq.Request__c);
}
If (lstTertiaryReq!= null && lstTertiaryReq.size() > 0) {
Reclassification_Request__c TertiaryReq = new Reclassification_Request__c();
TertiaryReq = lstTertiaryReq[0];
TertiaryReq.Request__c = 'Secondary Request';
update TertiaryReq;
}
} else if (RR.Request__c == 'Secondary Request')
{
If (lstTertiaryReq!= null && lstTertiaryReq.size() > 0) {
Reclassification_Request__c TertiaryReq = new Reclassification_Request__c();
TertiaryReq = lstTertiaryReq[0];
TertiaryReq.Request__c = 'Secondary Request';
update TertiaryReq;
}
}
}
-
- Subha Ayyappan 7
- June 02, 2016
- Like
- 0
- Continue reading or reply
Javascript to Check the Required Fields
Can anybody help me to write a javascript to check "if the field is blank in a visualforce page" and show the error messages below the field itself? I am new to javascript and not knowing how to write the JS code. Thank you.
-
- Subha Ayyappan 7
- May 23, 2016
- Like
- 0
- Continue reading or reply
SOQL to get the records created in a day, week and month
Hi all,
I want to get the records of an object created in a day, week and month all in the same query. Is it possible?
I want to get the records of an object created in a day, week and month all in the same query. Is it possible?
-
- Subha Ayyappan 7
- November 04, 2015
- Like
- 0
- Continue reading or reply
How can I Order My List as the order of Another List?
Hi ,
I need help in ordering the List. I have a List where the Field Priority__C must be ordered as Primary,Secondary, Tertiary,Fourth,Fifth,Sixth etc.. This order is in another List if Strings.
The user can change the priority of the record, and after resequencing the priority the order must be same again as Primary, Secondary etc...
I tried ORDER BY Id. But when the priority is changed the Id remains same and so not able to get the ordering.
Please help.
I need help in ordering the List. I have a List where the Field Priority__C must be ordered as Primary,Secondary, Tertiary,Fourth,Fifth,Sixth etc.. This order is in another List if Strings.
The user can change the priority of the record, and after resequencing the priority the order must be same again as Primary, Secondary etc...
I tried ORDER BY Id. But when the priority is changed the Id remains same and so not able to get the ordering.
Please help.
- Subha Ayyappan 7
- June 22, 2016
- Like
- 0
- Continue reading or reply
The return value of apex method to be used to check a condition in javascript in the visualforce page
Can anybody help me solve this issue?
I want to check if the user selects duplicate value of the picklist when many records are displayed to edit and show the error message and stop if duplicate is found.
I wrote a apex method for the same. Now how to take the return value to check the condition to show the error message in javascript?
My apex method is :
public Integer getcheckDuplicate() {
// RequestsList = new List<Reclassification_Request__c>();
for(integer i=0 ; i<RequestsList.size();i++) {
system.debug('Entering First For Loop');
for( integer j=(i+1) ; j<RequestsList.size() ;j++) {
Reclassification_Request__c reclassreqI = RequestsList.get(i);
system.debug(reclassreqI);
Reclassification_Request__c reclassreqJ = RequestsList.get(j);
system.debug(reclassreqJ);
if(reclassreqI.Request__c != 'Other') {
if(reclassreqI.Request__c == reclassreqJ.Request__c) {
system.debug('Duplicate Found');
// ApexPages.addmessage(new ApexPages.message(ApexPages.severity.WARNING,'Error:Priority may not be duplicated.'));
ErrorCount = ErrorCount+1;
}
}
}
}
return ErrorCount;
}
I want the check the value of ErrorCount and show the error message. But the value is always 0. Why? Any help please...
I want to check if the user selects duplicate value of the picklist when many records are displayed to edit and show the error message and stop if duplicate is found.
I wrote a apex method for the same. Now how to take the return value to check the condition to show the error message in javascript?
My apex method is :
public Integer getcheckDuplicate() {
// RequestsList = new List<Reclassification_Request__c>();
for(integer i=0 ; i<RequestsList.size();i++) {
system.debug('Entering First For Loop');
for( integer j=(i+1) ; j<RequestsList.size() ;j++) {
Reclassification_Request__c reclassreqI = RequestsList.get(i);
system.debug(reclassreqI);
Reclassification_Request__c reclassreqJ = RequestsList.get(j);
system.debug(reclassreqJ);
if(reclassreqI.Request__c != 'Other') {
if(reclassreqI.Request__c == reclassreqJ.Request__c) {
system.debug('Duplicate Found');
// ApexPages.addmessage(new ApexPages.message(ApexPages.severity.WARNING,'Error:Priority may not be duplicated.'));
ErrorCount = ErrorCount+1;
}
}
}
}
return ErrorCount;
}
I want the check the value of ErrorCount and show the error message. But the value is always 0. Why? Any help please...
- Subha Ayyappan 7
- June 16, 2016
- Like
- 0
- Continue reading or reply
Javascript to Check the Required Fields
Can anybody help me to write a javascript to check "if the field is blank in a visualforce page" and show the error messages below the field itself? I am new to javascript and not knowing how to write the JS code. Thank you.
- Subha Ayyappan 7
- May 23, 2016
- Like
- 0
- Continue reading or reply
Editing Vf Page
I am new to salesforce and i face a problem.
My problem is I want to redirect to the same visualforce page when New and Edit button is clicked from another Vf page.
Is it possible to change the Page Heading as "Add Request" when clicking Add and "Edit Request" when clicking Edit button? Please help
My problem is I want to redirect to the same visualforce page when New and Edit button is clicked from another Vf page.
Is it possible to change the Page Heading as "Add Request" when clicking Add and "Edit Request" when clicking Edit button? Please help
- Subha Savithri
- May 18, 2016
- Like
- 0
- Continue reading or reply
SOQL to get the records created in a day, week and month
Hi all,
I want to get the records of an object created in a day, week and month all in the same query. Is it possible?
I want to get the records of an object created in a day, week and month all in the same query. Is it possible?
- Subha Ayyappan 7
- November 04, 2015
- Like
- 0
- Continue reading or reply