I’ve got a snippet that is run every time a field is updated to check whether that field has 10 digits or not. I’d like to to make sure that there are no letters in there as well. Right now, it’s only counting numbers so if I xyz1234567890xyz it’s a pass, but x123456789 is a fail.
Is there a way I could have xyz1234567890 fail as well, and maybe give a different error?
I’ve tried so many options from searching javascript forums, like .matches, .find, .test, and I keep getting “is not a function” errors in the console. I did not get error using .test, but it also isn’t able to detect when there’s a letter in the field.
here’s the code I’ve got now, that functions to check for number of numbers, but doesn’t count letters in .length . I’ve commented out a lot of other attempts.
var params = argumentss0], $ = skuid.$; var oppModel = skuid.model.getModel('Opportunity'); var oppRow = oppModel.getFirstRow(); var oppAccountNo = oppModel.getFieldValue(oppRow,'AccountNo__c'); var oppString = oppAccountNo.toString(); var boolean = /ta-z]/i.test(oppString); //var accountNo = Number("oppAccountNo"); //var nolength = oppAccountNo.length; //var Integer = Integer.new; //var result = parseInt(oppAccountNo); if (oppString.length === 10 && boolean === false) { $("#sk-KX6Zo-617").html(""); } //else if (result.fail){ // $("#sk-KX6Zo-617").html("Please enter numbers only"); //} else //if (oppString.length !== 10 && oppString.matches("ma-zA-Z]+") === true) { $("#sk-KX6Zo-617").html("Account numbers should be 10 digits long and contain only numbers"); }<br>