JSFiddle - React, Tailwind, and code Playground
HTML
<!DOCTYPE HTML>
<script src="https://sapui5.netweaver.ondemand.com/resources/sap-ui-core.js"
id="sap-ui-bootstrap"
data-sap-ui-libs="sap.ui.commons,sap.ui.comp"
data-sap-ui-theme="sap_goldreflection">
</script>
<!-- add sap.ui.table,sap.ui.ux3 and/or other libraries to 'data-sap-ui-libs' if required -->
<script>
sap.ui.localResources("text");
var view = sap.ui.view({id:"idsample1", viewName:"text.sample", type:sap.ui.core.mvc.ViewType.JS});
view.placeAt("content");
</script>
</head>
<body class="sapUiBody" role="application">
<div id="content"></div>
</body>
</html>
JavaScript
var textbox = new sap.ui.commons.TextField("data",{});
textbox.attachBrowserEvent("keypress",function(e){
var key_codes = [48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 0, 8];
if (!($.inArray(e.which, key_codes) >= 0)) {
e.preventDefault();
}
});
var fileUp = new sap.ui.unified.FileUploader("fileUpload1", {
name : "upload2",
multiple : true,
maximumFileSize : 100,
width : "100%",
visible: true,
uploadOnChange : true,
uploadUrl : "attachment/uploadDocument",
placeholder : "",
fileSizeExceed : function(oEvent) {
var sName = oEvent.getParameter("fileName");
var fSize = oEvent.getParameter("fileSize");
var fLimit = oFileUploader2.getMaximumFileSize();
sap.m.MessageToast.show("File: " + sName + " is of size " + fSize + " MB which exceeds the file size limit of " + fLimit
+ " MB.",{duration: 3000,
width: '16em',
my: 'center center',
at: 'center center'
});
},
typeMissmatch : function(oEvent) {
var sName = oEvent.getParameter("fileName");
var sType = oEvent.getParameter("fileType");
},
change : function(oEvent) {
var iValue = oEvent.getSource().getValue();
if(iValue && iValue.length > 0 ){
// It Only allows a-z, A-Z, 0-9, Space, Underscore and dash.
var valid = /^([a-zA-Z0-9 _.-]+)$/gi.test(iValue.replace(/['"]+/g, '')); // /[`~!@#$%^&*|+\-=?;:'",<>\{\}\\\/]/gi.test(iValue.replace(/['"]+/g, '')); ///[`~!@#$%^&*()_|+\-=?;:'",.<>\{\}\[\]\\\/]/gi.test(iValue);
if (!valid) {
sap.m.MessageToast.show("File name can contain Number,Character,Underscore,dot and dash !",{duration: 3000,
width: '16em',
my: 'center center',
at: 'center center'
});
oEvent.getSource().setValue('');
return false;
}
}
},
uploadComplete : function(oEvent) {
}
});
...