PDA

View Full Version : Validating grid column and pass it ot a form



sachintaware
3 Jan 2012, 3:45 AM
Hello

Earlier i have got working an email application and this is a sms one.
So, I have to extract the phone numbers from the grid(Achieved this .)

But,the problem is in the Validation.I have to validate the numbers before sending them to the senders list.
i.e the list has mobile no and fixed line numbers(which cant receive sms).So I have to eliminate the bad data.

This is the code(below) to get the numbers but before setting the values i need to validate them in the required format.

1) Get the length of the number and if it is greater or less then 10.(Valid mobile number)
2) After checking length,eliminating irrelevant nos and prepend each number with the country code i.e 91.

After these checks the numbers will be in the required format and can be used.




var smsbtn = new Ext.Button({
text :'Send SMS',
scale :'large',
enableToggle:true,
renderTo:'buttonSms',
handler : function(){

var phnNo = new Array();
for(var j=0; j< store_company.getCount(); j++)
{

phnNo.push(store_company.getAt(j).get('statename'));


Ext.getCmp('sms-to').setValue(phnNo);
Ext.getCmp('send-sms-window').show();
}
}

});


Hoping for comments

Regards
Sach

mitchellsimoens
3 Jan 2012, 6:19 AM
If the phone number is a string then there is a length property of that string. If it is a number, see if it's greater than 999999999. If it passes the add the country code to it.

sachintaware
3 Jan 2012, 11:30 PM
Thanks mitchellsimoens

.length and a bit of concatenation was all that i had to do.

Thanks for the reply.

Regards
Sachin