0

Im trying to implement a validation for an input field in IBM BPM. Im not really familiar with java script but I try to get method that returns ture if a string contains any numbers.

awdadw = valid
awdawd2d = invalid

I tried this method:

function hasNumbers(t)
{
    var pattern=new RegExp("^[A-Za-z]+$"); 
    return pattern.test(t); // true if string. Returns false for numbers
}

When I try this function, it says that method / variable RegExp is unknown. Since it is rather basci stuff I hope to get some sources where this topic is explained.

James Donnelly
  • 126,410
  • 34
  • 208
  • 218
Julian Herbold
  • 537
  • 9
  • 20

2 Answers2

2

You can use this:

function validate(){    
var re = /^[A-Za-z]+$/;
if(re.test(document.getElementById("inputID").value))
   alert('Valid Name.');
else
   alert('Invalid Name.');      
  }
yardie
  • 1,583
  • 1
  • 14
  • 29
0

Based on adre3wap this worked for me:

function validate(t){
  var re = /^[A-Za-z]+$/;
  if(re.test(t))
     return false;
  else
     return true;
}
yardie
  • 1,583
  • 1
  • 14
  • 29
Julian Herbold
  • 537
  • 9
  • 20