0

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?

1
  • So many mistakes you have , dude , cmon :D buttin instead of button , lenght instead of length See my answer ;) Commented Dec 20, 2013 at 8:48

1 Answer 1

1
var temp = $('input[value=Save]').click;
$('input[value=Save]').click(Validate);

function Validate() {
    if ($('input[title=title1]').val().length != 14) {
        alert("The field not valid!");
    }else {
        temp();
    }
}

DEMO

Also, check naming of variables when you code! :) Good Luck!

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.