I have Input text and button save. This is elements generate server. And I want override function, which call button save. This is part of my HTML code:
Phone: < input type = "text"
name = "Phone"
title = "title1"
value = "(999) 999-9999" > < input class = "ms-ButtonHeightWidth"
type = "button"
target = "_self"
accesskey = "O"
onclick = "if (!PreSaveItem()) return false;WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions("
ctl00$ctl19$g_491cf573_1d26_479b_ba3e_73aecb248dcb$ctl00$toolBarTbl$RightRptControls$ctl00$ctl00$diidIOSaveItem ", "
", true, "
", "
", false, true))"
value = "Save" >
Can you help me write the function on JQuery like this:
<script type="text/javascript">
$(document).ready(function () {
var buttonSave = $('[value="Save"]');
var tempOnClick = buttinSave.Onclick;
buttinSave.Onclick = Validate();
function Validate() {
if ($('[title="title1"]').text.lenght == 14) {
tempOnClick.click();
} else {
alert("The field not valid!");
}
}
});
</script>
I whant, when user click button save, call my function Validate And if input textbox has 14 symbol call default fucntion. It's possible?
buttininstead ofbutton,lenghtinstead oflengthSee my answer ;)