Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

Adobe Summit 2023 [19th to 23rd March, Las Vegas and Virtual] | Complete AEM Session & Lab list

Validating Complicated Required Field

Avatar

Level 1
I am trying to come up with the correct validation scipt for a field that requires 13 characters - either numbers or numbers and x's, but does not allow for dashes, other letters or other characters. It is used for ISBN, and needs to be regulated because the professors cannot seem to grasp what is required. Can anyone help?
2 Replies

Avatar

Level 6
Here you go. Put this in the validate event for your field. It will strip out any characters other than 0123456789xX and then check that the result has 13 characters.



validateISBN(this.rawValue);



function validateISBN(s) {

var rExp = /[^0123456789xX]/gi;

var strFilteredString = s.replace(rExp, "");

this.rawValue = strFilteredString;

return (strFilteredString.length == 13)

}



Jared Langdon

www.jlangdon.ca

Avatar

Level 1
Thank you. This worked great for what I need. Your help is much appreciated.

The ultimate experience is back.

Join us in Vegas to build skills, learn from the world's top brands, and be inspired.

Register Now