Quantcast
Channel: Adobe Community : All Content - LiveCycle Designer
Viewing all articles
Browse latest Browse all 5571

How to check the space(s) in a text field?

$
0
0

I have a text field with the following validation rules:

  1. not null or empty;
  2. alphanumeric;
  3. 8 characters
  4. no space between or before/after

 

I wrote some Javascript functions to do the rules 1,2,3, but don't know how to do with 4:

1. check if null or empty

function isEmpty(str) {
if(str == null || str.length == 0) {
  return true;
}
return false;
}

2. check if alphanumeric

function validateAlphaNumeric( strVal ) {
var regExp  = /^[a-zA-Z0-9 ]*$/;
return regExp.test(strVal);
}

3. check if 8 characters

function validateInputLength( str, length ) {

if(str.length == length ){

  return true;

}

return false;

}

 

Is there a way that I update check 2 with a regular expression including check 4 (check if any space bar input)? Or shall I use a for loop to check the whole string, if so, how? Or any other solutions? Sorry, I am not very good in Javascripts and regular expressions.

 

Thanks

Sam


Viewing all articles
Browse latest Browse all 5571

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>