sachintaware
5 Jan 2012, 10:56 PM
Hello
Use Case:I have a form for my SMS application(sending sms notifications to users),which has a text area field for typing or copy/pasting the message.
I want a limit on the number of characters entered to '160'(standard message length).Also,I want to display the number of characters entered currently at the bottom of window.
If user enter's happy(5 chars) the text box below should display '155 remaining'.
I have used maxLength but I also want it to read the characters to make it better for the user,as it is an sms application,it expects this to be done.
var smsForm = new Ext.form.FormPanel({
//url: 'ValidationServlet',
frame:true,
title: 'SMS Form',
width: 350,
id:'sendSmsForm',
defaults: {width: 230},
defaultType: 'textfield',
items: [{
fieldLabel: 'Send To',
name:'toSms',
fieldWidth: 60,
id: 'sms-to',
msgTarget: 'side',
allowBlank: false,
x: 5,
y: 5,
anchor: '-5' // anchor width by percentage
}, /*{
fieldLabel: 'Subject',
name:'subject',
fieldWidth: 60,
x: 5,
y: 35,
anchor: '-5' // anchor width by percentage
},*/ {
x:5,
y: 65,
xtype: 'textarea',
name:'message',
fieldWidth: 90,
style: 'margin:0',
hideLabel: true,
anchor: '-5 -5', // anchor width and height
maxLength:160
}
],
buttons: [{
text: 'Send',
handler: function(){
var f = Ext.getCmp('sendSmsForm');
f.form.submit({
reset: true,
url:'EmailServlet',
method:'Post',
waitMsg:'Sending Message...',
success:function(form,action){
Ext.Msg.alert('Status', 'Message has been sent Successfully!!', function(btn, text){
if (btn == 'ok'){
// var redirect = 'success.html';
// window.location = redirect;
}
});
}
});
}
}]
});
win = Ext.widget('window', {
// title: 'Email Form',
closeAction: 'hide',
width: 500,
height: 400,
id:'send-sms-window',
minHeight: 400,
layout: 'fit',
resizable: true,
modal: true,
items: smsForm
});
Regards
Sachin
Use Case:I have a form for my SMS application(sending sms notifications to users),which has a text area field for typing or copy/pasting the message.
I want a limit on the number of characters entered to '160'(standard message length).Also,I want to display the number of characters entered currently at the bottom of window.
If user enter's happy(5 chars) the text box below should display '155 remaining'.
I have used maxLength but I also want it to read the characters to make it better for the user,as it is an sms application,it expects this to be done.
var smsForm = new Ext.form.FormPanel({
//url: 'ValidationServlet',
frame:true,
title: 'SMS Form',
width: 350,
id:'sendSmsForm',
defaults: {width: 230},
defaultType: 'textfield',
items: [{
fieldLabel: 'Send To',
name:'toSms',
fieldWidth: 60,
id: 'sms-to',
msgTarget: 'side',
allowBlank: false,
x: 5,
y: 5,
anchor: '-5' // anchor width by percentage
}, /*{
fieldLabel: 'Subject',
name:'subject',
fieldWidth: 60,
x: 5,
y: 35,
anchor: '-5' // anchor width by percentage
},*/ {
x:5,
y: 65,
xtype: 'textarea',
name:'message',
fieldWidth: 90,
style: 'margin:0',
hideLabel: true,
anchor: '-5 -5', // anchor width and height
maxLength:160
}
],
buttons: [{
text: 'Send',
handler: function(){
var f = Ext.getCmp('sendSmsForm');
f.form.submit({
reset: true,
url:'EmailServlet',
method:'Post',
waitMsg:'Sending Message...',
success:function(form,action){
Ext.Msg.alert('Status', 'Message has been sent Successfully!!', function(btn, text){
if (btn == 'ok'){
// var redirect = 'success.html';
// window.location = redirect;
}
});
}
});
}
}]
});
win = Ext.widget('window', {
// title: 'Email Form',
closeAction: 'hide',
width: 500,
height: 400,
id:'send-sms-window',
minHeight: 400,
layout: 'fit',
resizable: true,
modal: true,
items: smsForm
});
Regards
Sachin