Pre-requisites
1.sapui5 framework
2.basic javascript knowledge
Validation of input data is important in every application.Today we will see how to do email validation in sapui5.For this we will make use of regular expressions.regular expressions are a series or sequence of symbols and characters expressing a pattern to be searched for within another string.
Steps
1.Create an input box.
regular expression used for email validation is /^\w+[\w-+\.]*\@\w+([-\.]\w+)*\.[a-zA-Z]{2,}$/.
sample code goes here.
email validation
Validation of input data is important in every application.Today we will see how to do email validation in sapui5.For this we will make use of regular expressions.regular expressions are a series or sequence of symbols and characters expressing a pattern to be searched for within another string.
Steps
1.Create an input box.
rInput = new sap.m.Input({});2.attach the validation logic in change event of input box.a change event is fired when a user press enter.
regular expression used for email validation is /^\w+[\w-+\.]*\@\w+([-\.]\w+)*\.[a-zA-Z]{2,}$/.
change: function() { email = rInput.getValue(); mailregex = /^\w+[\w-+\.]*\@\w+([-\.]\w+)*\.[a-zA-Z]{2,}$/; if (!email.match(mailregex)) { //alert("Invalid Email"); rInput.setValueState("Error"); } else { rInput.setValueState("None"); } }We made use of setValueState() method to show error state of input box.
sample code goes here.
email validation
If you enjoyed this post, Please Share!!
0 comments :
Post a Comment