I saved a function created in jQuery in clean.js file..
jQuery.fn.singleDotHyphen = function(){
return this.each(function(){
var $this = $(this);
$this.val(function(){
return $this.val()
.replace(/\.{2,}/g, '.')
.replace(/-{2,}/g, '-');
});
});
};
My action file is..
<script type="text/javascript">
$(document).ready(function() {
$.noConflict();
$('#title').limitkeypress ({ rexp:/^[A-Za-z.\-\s`]*$/ });
$('#title').blur(function() {
$(this).singleDotHyphen();
});
});
</script>
Issue is onblur its returning me code of the function where as I want to return the string that reject continuous hyphen and dots…
The version of the
.val()method that accepts a function argument exists only in jQuery 1.4 and above. However, in this case you don’t need that version, since you can simply pass the new value toval():