Monday, 7 September 2015

Substring in javascript

Substring in Javascript:

The substr() method returns the characters in a string beginning at the specified location through the specified number of characters.

Syntax

str.substr(start[, length])
 
 
Frappe Example

frappe.ui.form.on("Quotation", "validate", function(frm) {
       var a = frm.doc.customer;
       a= a.substr(0,3);
        msgprint(a);
});

Above script returns first three letter  of customer name.


reference:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/substr
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/slice

No comments:

Post a Comment